diff --git a/manifests/compute/libvirt.pp b/manifests/compute/libvirt.pp index af01cc61b..3f8543fe4 100644 --- a/manifests/compute/libvirt.pp +++ b/manifests/compute/libvirt.pp @@ -9,7 +9,7 @@ # (optional) The state of nova packages # Defaults to 'present' # -# [*libvirt_virt_type*] +# [*virt_type*] # (optional) Libvirt domain type. Options are: kvm, lxc, qemu, uml, xen # Defaults to 'kvm' # @@ -21,60 +21,60 @@ # (optional) Whether to support virtual machine migration # Defaults to false # -# [*libvirt_cpu_mode*] +# [*cpu_mode*] # (optional) The libvirt CPU mode to configure. Possible values # include custom, host-model, none, host-passthrough. -# Defaults to 'host-model' if libvirt_virt_type is set to kvm, +# Defaults to 'host-model' if virt_type is set to kvm, # otherwise defaults to 'none'. # -# [*libvirt_cpu_model*] +# [*cpu_model*] # (optional) The named libvirt CPU model (see names listed in # /usr/share/libvirt/cpu_map.xml). Only has effect if # cpu_mode="custom" and virt_type="kvm|qemu". # Defaults to undef # -# [*libvirt_cpu_model_extra_flags*] +# [*cpu_model_extra_flags*] # (optional) This allows specifying granular CPU feature flags when # specifying CPU models. Only has effect if cpu_mode is not set # to 'none'. # Defaults to undef # -# [*libvirt_snapshot_image_format*] +# [*snapshot_image_format*] # (optional) Format to save snapshots to. Some filesystems # have a preference and only operate on raw or qcow2 # Defaults to $::os_service_default # -# [*libvirt_disk_cachemodes*] +# [*disk_cachemodes*] # (optional) A list of cachemodes for different disk types, e.g. # ["file=directsync", "block=none"] # If an empty list is specified, the disk_cachemodes directive # will be removed from nova.conf completely. # Defaults to an empty list # -# [*libvirt_hw_disk_discard*] +# [*hw_disk_discard*] # (optional) Discard option for nova managed disks. Need Libvirt(1.0.6) # Qemu1.5 (raw format) Qemu1.6(qcow2 format). # Defaults to $::os_service_default # -# [*libvirt_hw_machine_type*] +# [*hw_machine_type*] # (optional) Option to specify a default machine type per host architecture. # Defaults to $::os_service_default # -# [*libvirt_inject_password*] +# [*inject_password*] # (optional) Inject the admin password at boot time, without an agent. # Defaults to false # -# [*libvirt_inject_key*] +# [*inject_key*] # (optional) Inject the ssh public key at boot time. # Defaults to false # -# [*libvirt_inject_partition*] +# [*inject_partition*] # (optional) The partition to inject to : -2 => disable, -1 => inspect # (libguestfs only), 0 => not partitioned, >0 => partition # number (integer value) # Defaults to -2 # -# [*libvirt_enabled_perf_events*] +# [*enabled_perf_events*] # (optional) This is a performance event list which could be used as monitor. # A string list. For example: ``enabled_perf_events = cmt, mbml, mbmt`` # The supported events list can be found in @@ -195,23 +195,91 @@ # class, this is used to generate the resource class name as # CUSTOM_PMEM_NAMESPACE_$LABEL. # Defaults to $::os_service_default - +# +# DEPRECATED PARAMETERS +# +# [*libvirt_virt_type*] +# (optional) Libvirt domain type. Options are: kvm, lxc, qemu, uml, xen +# Defaults to undef +# +# [*libvirt_cpu_mode*] +# (optional) The libvirt CPU mode to configure. Possible values +# include custom, host-model, none, host-passthrough. +# Defaults to 'host-model' if libvirt_virt_type is set to kvm, +# Defaults to undef +# +# [*libvirt_cpu_model*] +# (optional) The named libvirt CPU model (see names listed in +# /usr/share/libvirt/cpu_map.xml). Only has effect if +# cpu_mode="custom" and virt_type="kvm|qemu". +# Defaults to undef +# +# [*libvirt_cpu_model_extra_flags*] +# (optional) This allows specifying granular CPU feature flags when +# specifying CPU models. Only has effect if cpu_mode is not set +# to 'none'. +# Defaults to undef +# +# [*libvirt_snapshot_image_format*] +# (optional) Format to save snapshots to. Some filesystems +# have a preference and only operate on raw or qcow2 +# Defaults to undef +# +# [*libvirt_disk_cachemodes*] +# (optional) A list of cachemodes for different disk types, e.g. +# ["file=directsync", "block=none"] +# If an empty list is specified, the disk_cachemodes directive +# will be removed from nova.conf completely. +# Defaults to undef +# +# [*libvirt_hw_disk_discard*] +# (optional) Discard option for nova managed disks. Need Libvirt(1.0.6) +# Qemu1.5 (raw format) Qemu1.6(qcow2 format). +# Defaults to undef +# +# [*libvirt_hw_machine_type*] +# (optional) Option to specify a default machine type per host architecture. +# Defaults to undef +# +# [*libvirt_inject_password*] +# (optional) Inject the admin password at boot time, without an agent. +# Defaults to undef +# +# [*libvirt_inject_key*] +# (optional) Inject the ssh public key at boot time. +# Defaults to undef +# +# [*libvirt_inject_partition*] +# (optional) The partition to inject to : -2 => disable, -1 => inspect +# (libguestfs only), 0 => not partitioned, >0 => partition +# number (integer value) +# Defaults to -2 +# Defaults to undef +# +# [*libvirt_enabled_perf_events*] +# (optional) This is a performance event list which could be used as monitor. +# A string list. For example: ``enabled_perf_events = cmt, mbml, mbmt`` +# The supported events list can be found in +# https://libvirt.org/html/libvirt-libvirt-domain.html , +# which you may need to search key words ``VIR_PERF_PARAM_*`` +# Defaults to undef +# class nova::compute::libvirt ( $ensure_package = 'present', - $libvirt_virt_type = 'kvm', + $virt_type = 'kvm', $vncserver_listen = '127.0.0.1', $migration_support = false, - $libvirt_cpu_mode = false, - $libvirt_cpu_model = undef, - $libvirt_cpu_model_extra_flags = undef, - $libvirt_snapshot_image_format = $::os_service_default, - $libvirt_disk_cachemodes = [], - $libvirt_hw_disk_discard = $::os_service_default, - $libvirt_hw_machine_type = $::os_service_default, - $libvirt_inject_password = false, - $libvirt_inject_key = false, - $libvirt_inject_partition = -2, - $libvirt_enabled_perf_events = $::os_service_default, + $cpu_mode = false, + $cpu_model = undef, + $cpu_model_extra_flags = undef, + $snapshot_image_format = $::os_service_default, + $disk_cachemodes = [], + $hw_disk_discard = $::os_service_default, + $hw_machine_type = $::os_service_default, + $inject_password = false, + $inject_key = false, + $inject_partition = -2, + $enabled_perf_events = $::os_service_default, $remove_unused_base_images = $::os_service_default, $remove_unused_resized_minimum_age_seconds = $::os_service_default, $remove_unused_original_minimum_age_seconds = $::os_service_default, @@ -232,27 +300,136 @@ class nova::compute::libvirt ( $log_filters = undef, $tls_priority = undef, $pmem_namespaces = $::os_service_default, + # DEPRECATED PARAMETERS + $libvirt_virt_type = undef, + $libvirt_cpu_mode = undef, + $libvirt_cpu_model = undef, + $libvirt_cpu_model_extra_flags = undef, + $libvirt_snapshot_image_format = undef, + $libvirt_disk_cachemodes = undef, + $libvirt_hw_disk_discard = undef, + $libvirt_hw_machine_type = undef, + $libvirt_inject_password = undef, + $libvirt_inject_key = undef, + $libvirt_inject_partition = undef, + $libvirt_enabled_perf_events = undef, ) inherits nova::params { include nova::deps include nova::params - # libvirt_cpu_mode has different defaults depending on hypervisor. - if !$libvirt_cpu_mode { - case $libvirt_virt_type { + if $libvirt_virt_type != undef { + warning('The libvirt_virt_type parameter was deprecated and will be removed \ +in a future release. Use the virt_type parameter instead') + $virt_type_real = $libvirt_virt_type + } else { + $virt_type_real = $virt_type + } + + if $libvirt_cpu_mode != undef { + warning('The libvirt_cpu_mode parameter was deprecated and will be removed \ +in a future release. Use the cpu_mode parameter instead') + $cpu_mode_real = $libvirt_cpu_mode + } else { + $cpu_mode_real = $cpu_mode + } + + if $libvirt_cpu_model != undef { + warning('The libvirt_cpu_model parameter was deprecated and will be removed \ +in a future release. Use the cpu_model parameter instead') + $cpu_model_real = $libvirt_cpu_model + } else { + $cpu_model_real = $cpu_model + } + + if $libvirt_cpu_model_extra_flags != undef { + warning('The libvirt_cpu_model_extra_flags parameter was deprecated and will be removed \ +in a future release. Use the cpu_model_extra_flags parameter instead') + $cpu_model_extra_flags_real = $libvirt_cpu_model_extra_flags + } else { + $cpu_model_extra_flags_real = $cpu_model_extra_flags + } + + if $libvirt_snapshot_image_format != undef { + warning('The libvirt_snapshot_image_format parameter was deprecated and will be removed \ +in a future release. Use the snapshot_image_format parameter instead') + $snapshot_image_format_real = $libvirt_snapshot_image_format + } else { + $snapshot_image_format_real = $snapshot_image_format + } + + if $libvirt_disk_cachemodes != undef { + warning('The libvirt_disk_cachemodes parameter was deprecated and will be removed \ +in a future release. Use the disk_cachemodes parameter instead') + $disk_cachemodes_real = $libvirt_disk_cachemodes + } else { + $disk_cachemodes_real = $disk_cachemodes + } + + if $libvirt_hw_disk_discard != undef { + warning('The libvirt_hw_disk_discard parameter was deprecated and will be removed \ +in a future release. Use the hw_disk_discard parameter instead') + $hw_disk_discard_real = $libvirt_hw_disk_discard + } else { + $hw_disk_discard_real = $hw_disk_discard + } + + if $libvirt_hw_machine_type != undef { + warning('The libvirt_hw_machine_type parameter was deprecated and will be removed \ +in a future release. Use the hw_machine_type parameter instead') + $hw_machine_type_real = $libvirt_hw_machine_type + } else { + $hw_machine_type_real = $hw_machine_type + } + + if $libvirt_inject_password != undef { + warning('The libvirt_inject_password parameter was deprecated and will be removed \ +in a future release. Use the inject_password parameter instead') + $inject_password_real = $libvirt_inject_password + } else { + $inject_password_real = $inject_password + } + + if $libvirt_inject_key != undef { + warning('The libvirt_inject_key parameter was deprecated and will be removed \ +in a future release. Use the inject_key parameter instead') + $inject_key_real = $libvirt_inject_key + } else { + $inject_key_real = $inject_key + } + + if $libvirt_inject_partition != undef { + warning('The libvirt_inject_partition parameter was deprecated and will be removed \ +in a future release. Use the inject_partition parameter instead') + $inject_partition_real = $libvirt_inject_partition + } else { + $inject_partition_real = $inject_partition + } + + if $libvirt_enabled_perf_events != undef { + warning('The libvirt_enabled_perf_events parameter was deprecated and will be removed \ +in a future release. Use the enabled_perf_events parameter instead') + $enabled_perf_events_real = $libvirt_enabled_perf_events + } else { + $enabled_perf_events_real = $enabled_perf_events + } + + # cpu_mode has different defaults depending on hypervisor. + if !$cpu_mode_real { + case $virt_type_real { 'kvm': { - $libvirt_cpu_mode_real = 'host-model' + $cpu_mode_default = 'host-model' } default: { - $libvirt_cpu_mode_real = 'none' + $cpu_mode_default = 'none' } } } else { - $libvirt_cpu_mode_real = $libvirt_cpu_mode + $cpu_mode_default = $cpu_mode_real } if($::osfamily == 'Debian') { - package { "nova-compute-${libvirt_virt_type}": + package { "nova-compute-${virt_type_real}": ensure => $ensure_package, tag => ['openstack', 'nova-package'], } @@ -318,7 +495,7 @@ class nova::compute::libvirt ( libvirt_service_name => $libvirt_service_name, virtlock_service_name => $virtlock_service_name, virtlog_service_name => $virtlog_service_name, - libvirt_virt_type => $libvirt_virt_type, + libvirt_virt_type => $virt_type_real, } } @@ -326,15 +503,15 @@ class nova::compute::libvirt ( 'DEFAULT/compute_driver': value => $compute_driver; 'DEFAULT/preallocate_images': value => $preallocate_images; 'vnc/server_listen': value => $vncserver_listen; - 'libvirt/virt_type': value => $libvirt_virt_type; - 'libvirt/cpu_mode': value => $libvirt_cpu_mode_real; - 'libvirt/snapshot_image_format': value => $libvirt_snapshot_image_format; - 'libvirt/inject_password': value => $libvirt_inject_password; - 'libvirt/inject_key': value => $libvirt_inject_key; - 'libvirt/inject_partition': value => $libvirt_inject_partition; - 'libvirt/hw_disk_discard': value => $libvirt_hw_disk_discard; - 'libvirt/hw_machine_type': value => $libvirt_hw_machine_type; - 'libvirt/enabled_perf_events': value => join(any2array($libvirt_enabled_perf_events), ','); + 'libvirt/virt_type': value => $virt_type_real; + 'libvirt/cpu_mode': value => $cpu_mode_default; + 'libvirt/snapshot_image_format': value => $snapshot_image_format_real; + 'libvirt/inject_password': value => $inject_password_real; + 'libvirt/inject_key': value => $inject_key_real; + 'libvirt/inject_partition': value => $inject_partition_real; + 'libvirt/hw_disk_discard': value => $hw_disk_discard_real; + 'libvirt/hw_machine_type': value => $hw_machine_type_real; + 'libvirt/enabled_perf_events': value => join(any2array($enabled_perf_events_real), ','); 'libvirt/rx_queue_size': value => $rx_queue_size; 'libvirt/tx_queue_size': value => $tx_queue_size; 'libvirt/file_backed_memory': value => $file_backed_memory; @@ -347,37 +524,37 @@ class nova::compute::libvirt ( # cpu_model param is only valid if cpu_mode=custom # otherwise it should be commented out - if $libvirt_cpu_mode_real == 'custom' { - validate_legacy(String, 'validate_string', $libvirt_cpu_model) + if $cpu_mode_default == 'custom' { + validate_legacy(String, 'validate_string', $cpu_model_real) nova_config { - 'libvirt/cpu_model': value => $libvirt_cpu_model; + 'libvirt/cpu_model': value => $cpu_model_real; } } else { nova_config { 'libvirt/cpu_model': ensure => absent; } - if $libvirt_cpu_model { - warning('$libvirt_cpu_model requires that $libvirt_cpu_mode => "custom" and will be ignored') + if $cpu_model_real { + warning('$cpu_model requires that $cpu_mode => "custom" and will be ignored') } } - if $libvirt_cpu_mode_real != 'none' and $libvirt_cpu_model_extra_flags { - validate_legacy(String, 'validate_string', $libvirt_cpu_model_extra_flags) + if $cpu_mode_default != 'none' and $cpu_model_extra_flags_real { + validate_legacy(String, 'validate_string', $cpu_model_extra_flags_real) nova_config { - 'libvirt/cpu_model_extra_flags': value => $libvirt_cpu_model_extra_flags; + 'libvirt/cpu_model_extra_flags': value => $cpu_model_extra_flags_real; } } else { nova_config { 'libvirt/cpu_model_extra_flags': ensure => absent; } - if $libvirt_cpu_model_extra_flags { - warning('$libvirt_cpu_model_extra_flags requires that $libvirt_cpu_mode is not set to "none" and will be ignored') + if $cpu_model_extra_flags_real { + warning('$cpu_model_extra_flags requires that $cpu_mode is not set to "none" and will be ignored') } } - if size($libvirt_disk_cachemodes) > 0 { + if size($disk_cachemodes_real) > 0 { nova_config { - 'libvirt/disk_cachemodes': value => join($libvirt_disk_cachemodes, ','); + 'libvirt/disk_cachemodes': value => join($disk_cachemodes_real, ','); } } else { nova_config { diff --git a/releasenotes/notes/compute-libvirt-rename-params-663631444f02c946.yaml b/releasenotes/notes/compute-libvirt-rename-params-663631444f02c946.yaml new file mode 100644 index 000000000..daf9bad61 --- /dev/null +++ b/releasenotes/notes/compute-libvirt-rename-params-663631444f02c946.yaml @@ -0,0 +1,19 @@ +--- +deprecations: + - | + The following parameters in the ``nova::compute::libvirt`` class have been + renamed to shorten names without ``libvirt_`` prefix. The old parameter + names have been deprecated and will be removed in a future release. + + - ``libvirt_virt_type`` + - ``libvirt_cpu_mode`` + - ``libvirt_cpu_model`` + - ``libvirt_cpu_model_extra_flags`` + - ``libvirt_snapshot_image_format`` + - ``libvirt_disk_cachemodes`` + - ``libvirt_hw_disk_discard`` + - ``libvirt_hw_machine_type`` + - ``libvirt_inject_password`` + - ``libvirt_inject_key`` + - ``libvirt_inject_partition`` + - ``libvirt_enabled_perf_events`` diff --git a/spec/classes/nova_compute_libvirt_spec.rb b/spec/classes/nova_compute_libvirt_spec.rb index c5e8ebac5..5d5b641bc 100644 --- a/spec/classes/nova_compute_libvirt_spec.rb +++ b/spec/classes/nova_compute_libvirt_spec.rb @@ -75,16 +75,16 @@ describe 'nova::compute::libvirt' do describe 'with params' do let :params do { :ensure_package => 'latest', - :libvirt_virt_type => 'qemu', + :virt_type => 'qemu', :vncserver_listen => '0.0.0.0', - :libvirt_cpu_mode => 'host-passthrough', - :libvirt_cpu_model => 'kvm64', - :libvirt_cpu_model_extra_flags => 'pcid', - :libvirt_snapshot_image_format => 'raw', - :libvirt_disk_cachemodes => ['file=directsync','block=none'], - :libvirt_hw_disk_discard => 'unmap', - :libvirt_hw_machine_type => 'x86_64=machinetype1,armv7l=machinetype2', - :libvirt_enabled_perf_events => ['cmt', 'mbml', 'mbmt'], + :cpu_mode => 'host-passthrough', + :cpu_model => 'kvm64', + :cpu_model_extra_flags => 'pcid', + :snapshot_image_format => 'raw', + :disk_cachemodes => ['file=directsync','block=none'], + :hw_disk_discard => 'unmap', + :hw_machine_type => 'x86_64=machinetype1,armv7l=machinetype2', + :enabled_perf_events => ['cmt', 'mbml', 'mbmt'], :remove_unused_base_images => true, :remove_unused_resized_minimum_age_seconds => 3600, :remove_unused_original_minimum_age_seconds => 3600, @@ -158,9 +158,9 @@ describe 'nova::compute::libvirt' do describe 'with custom cpu_mode' do let :params do - { :libvirt_cpu_mode => 'custom', - :libvirt_cpu_model => 'kvm64', - :libvirt_cpu_model_extra_flags => 'pcid' } + { :cpu_mode => 'custom', + :cpu_model => 'kvm64', + :cpu_model_extra_flags => 'pcid' } end it { is_expected.to contain_nova_config('libvirt/cpu_mode').with_value('custom')} @@ -170,7 +170,7 @@ describe 'nova::compute::libvirt' do describe 'with qcow2 as snapshot_image_format' do let :params do - { :libvirt_snapshot_image_format => 'qcow2' } + { :snapshot_image_format => 'qcow2' } end it { is_expected.to contain_nova_config('libvirt/snapshot_image_format').with_value('qcow2')} @@ -178,7 +178,7 @@ describe 'nova::compute::libvirt' do describe 'with qemu as virt_type' do let :params do - { :libvirt_virt_type => 'qemu' } + { :virt_type => 'qemu' } end it { is_expected.to contain_nova_config('libvirt/cpu_mode').with_value('none')} @@ -300,12 +300,12 @@ describe 'nova::compute::libvirt' do describe 'with params' do let :params do - { :libvirt_virt_type => 'qemu', + { :virt_type => 'qemu', :vncserver_listen => '0.0.0.0', :remove_unused_base_images => true, :remove_unused_resized_minimum_age_seconds => 3600, :remove_unused_original_minimum_age_seconds => 3600, - :libvirt_enabled_perf_events => ['cmt', 'mbml', 'mbmt'], + :enabled_perf_events => ['cmt', 'mbml', 'mbmt'], :nfs_mount_options => 'rw,intr,nolock', :mem_stats_period_seconds => 20, }