diff --git a/.fixtures.yml b/.fixtures.yml index b7a8d350..bf4521a4 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -4,5 +4,6 @@ fixtures: apt: repo: "https://github.com/puppetlabs/puppetlabs-apt.git" ref: "1.8.0" + inifile: "https://github.com/puppetlabs/puppetlabs-inifile" symlinks: - one: "../../../" + one: "#{source_dir}" diff --git a/manifests/oned/config.pp b/manifests/oned/config.pp index 01067463..7a411bcb 100644 --- a/manifests/oned/config.pp +++ b/manifests/oned/config.pp @@ -52,7 +52,7 @@ $sched_log_debug_level = $one::sched_log_debug_level, $kvm_driver_emulator = $one::kvm_driver_emulator, $kvm_driver_nic_attrs = $one::kvm_driver_nic_attrs, - ) { +) { if ! member(['YES', 'NO'], $oned_vm_submit_on_hold) { fail("oned_vm_submit_on_hold must be one of 'YES' or 'NO'. Actual value: ${oned_vm_submit_on_hold}") @@ -123,11 +123,22 @@ source => $hook_scripts_path, } - file { '/etc/one/vmm_exec/vmm_exec_kvm.conf': - ensure => file, - owner => 'root', - mode => '0640', - content => template('one/vmm_exec_kvm.conf.erb'), + if $kvm_driver_emulator != 'undef' { + ini_setting{ 'set_kvm_driver_emulator': + ensure => present, + path => '/etc/one/vmm_exec/vmm_exec_kvm.conf', + setting => 'EMULATOR', + value => $kvm_driver_emulator, + } + } + + if $kvm_driver_nic_attrs != 'undef' { + ini_setting{ 'set_kvm_driver_nic': + ensure => present, + path => '/etc/one/vmm_exec/vmm_exec_kvm.conf', + setting => 'NIC', + value => $kvm_driver_nic_attrs, + } } if ($backend == 'mysql') { diff --git a/metadata.json b/metadata.json index 7d065c81..26598a39 100644 --- a/metadata.json +++ b/metadata.json @@ -24,6 +24,7 @@ ], "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": "> 2.2.0" }, - { "name": "puppetlabs/apt", "version_requirement": "< 2.0.0" } + { "name": "puppetlabs/apt", "version_requirement": "< 2.0.0" }, + { "name": "puppetlabs/inifile", "version_requirement": "< 1.4.0" } ] } diff --git a/spec/classes/one__oned__config_spec.rb b/spec/classes/one__oned__config_spec.rb index 8567407b..1f38de1e 100644 --- a/spec/classes/one__oned__config_spec.rb +++ b/spec/classes/one__oned__config_spec.rb @@ -8,6 +8,7 @@ let(:facts) { f } let (:hiera_config) { hiera_config } let (:pre_condition) { 'include one' } + context 'general' do it { should contain_class('one::oned::config') } it { should contain_file('/etc/one/oned.conf') \ @@ -26,6 +27,7 @@ } it { should contain_file('/usr/share/one').with_ensure('directory') } end + context 'with mysql backend' do let (:params) { { :backend => 'mysql', @@ -35,7 +37,28 @@ it { should contain_file('/srv/backup') } it { should contain_file('/var/lib/one/bin/one_db_backup.sh') } it { should contain_cron('one_db_backup') } + end + context 'without kvm driver emulator settings' do + it { should_not contain_ini_setting('set_kvm_driver_emulator') } + end + + context 'with kvm driver emulator settings' do + let(:params) { { + :kvm_driver_emulator => '/usr/bin/foobar/kvm-bogus' + } } + it { should contain_ini_setting('set_kvm_driver_emulator').with_value('/usr/bin/foobar/kvm-bogus') } + end + + context 'without kvm driver nic settings' do + it { should_not contain_ini_setting('set_kvm_driver_nic') } + end + + context 'with kvm driver nic settings' do + let(:params) { { + :kvm_driver_nic_attrs => '[ filter="clean-traffic", model="bogus" ]' + } } + it { should contain_ini_setting('set_kvm_driver_nic').with_value('[ filter="clean-traffic", model="bogus" ]') } end end end diff --git a/templates/vmm_exec_kvm.conf.erb b/templates/vmm_exec_kvm.conf.erb deleted file mode 100644 index afcade51..00000000 --- a/templates/vmm_exec_kvm.conf.erb +++ /dev/null @@ -1,61 +0,0 @@ -# -------------------------------------------------------------------------- # -# Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -# Default configuration attributes for the KVM driver -# (all domains will use these values as defaults). These values can -# be overridden in each VM template. Valid atributes are: -# - emulator -# - os [kernel,initrd,boot,root,kernel_cmd,arch,machine] -# - vcpu -# - features [acpi, pae, apic, hyperv, localtime] -# - disk [driver, cache, io, total_bytes_sec, total_iops_sec, read_bytes_sec, write_bytes_sec, read_iops_sec, write_iops_sec] -# - nic [filter, model] -# - raw -# - hyperv_options: options used for FEATURES = [ HYPERV = yes ] -# NOTE: raw attribute value is appended to that on the VM template - -#EMULATOR = /usr/libexec/qemu-kvm -<% if scope.lookupvar('one::kvm_driver_emulator') != 'undef' -%> -EMULATOR = <%= scope.lookupvar('one::kvm_driver_emulator') %> -<% end -%> - -#VCPU = 1 - -OS = [ boot = "hd", arch = "x86_64" ] -FEATURES = [ PAE = "no", ACPI = "yes", APIC = "no", HYPERV = "no" ] - -DISK = [ driver = "raw" , cache = "none"] - -#NIC = [ filter = "clean-traffic", model="virtio" ] -<% if scope.lookupvar('one::kvm_driver_nic_attrs') != 'undef' -%> -NIC = <%= scope.lookupvar('one::kvm_driver_nic_attrs') %> -<% end -%> -#RAW = "" - -HYPERV_OPTIONS="" - -SPICE_OPTIONS=" - - - - - - - - " -