diff --git a/deployment/puppet/openstack_tasks/manifests/openstack_network/compute_nova.pp b/deployment/puppet/openstack_tasks/manifests/openstack_network/compute_nova.pp index 6e85bef56d..fec0c1d276 100644 --- a/deployment/puppet/openstack_tasks/manifests/openstack_network/compute_nova.pp +++ b/deployment/puppet/openstack_tasks/manifests/openstack_network/compute_nova.pp @@ -43,7 +43,7 @@ class openstack_tasks::openstack_network::compute_nova { exec { 'destroy_libvirt_default_network': command => 'virsh net-destroy default', - onlyif => 'virsh net-info default | grep -qE "Active:.* yes"', + onlyif => "virsh net-list | grep -qE '^\s*default\s'", path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ], tries => 3, require => Service['libvirt'], @@ -51,13 +51,14 @@ class openstack_tasks::openstack_network::compute_nova { exec { 'undefine_libvirt_default_network': command => 'virsh net-undefine default', - onlyif => 'virsh net-info default 2>&1 > /dev/null', + onlyif => "virsh net-list --all | grep -qE '^\s*default\s'", path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ], tries => 3, require => Exec['destroy_libvirt_default_network'], } Service['libvirt'] ~> Exec['destroy_libvirt_default_network'] + Service['libvirt'] ~> Exec['undefine_libvirt_default_network'] # script called by qemu needs to manipulate the tap device file_line { 'clear_emulator_capabilities': diff --git a/tests/noop/spec/hosts/openstack-network/compute-nova_spec.rb b/tests/noop/spec/hosts/openstack-network/compute-nova_spec.rb index b96940de4c..08a817cfbc 100644 --- a/tests/noop/spec/hosts/openstack-network/compute-nova_spec.rb +++ b/tests/noop/spec/hosts/openstack-network/compute-nova_spec.rb @@ -99,17 +99,18 @@ describe manifest do :name => 'libvirtd' )} it { expect(subject).to contain_service('libvirt').that_notifies('Exec[destroy_libvirt_default_network]') } + it { expect(subject).to contain_service('libvirt').that_notifies('Exec[undefine_libvirt_default_network]') } # it { expect(subject).to contain_exec('destroy_libvirt_default_network').with( :command => 'virsh net-destroy default', - :onlyif => 'virsh net-info default | grep -qE "Active:.* yes"', + :onlyif => "virsh net-list | grep -qE '^\s*default\s'", :tries => 3, )} it { expect(subject).to contain_exec('destroy_libvirt_default_network').that_requires('Service[libvirt]')} # it { expect(subject).to contain_exec('undefine_libvirt_default_network').with( :command => 'virsh net-undefine default', - :onlyif => 'virsh net-info default 2>&1 > /dev/null', + :onlyif => "virsh net-list --all | grep -qE '^\s*default\s'", :tries => 3, )} it { expect(subject).to contain_exec('undefine_libvirt_default_network').that_requires('Exec[destroy_libvirt_default_network]')}