integ/config/puppet-modules/puppet-network/centos/files/fix-absent-options.patch
Scott Little bab9bb6b69 Internal restructuring of stx-integ
Create new directories:
   ceph
   config
   config-files
   filesystem
   kernel
   kernel/kernel-modules
   ldap
   logging
   strorage-drivers
   tools
   utilities
   virt

Retire directories:
   connectivity
   core
   devtools
   support
   extended

Delete two packages:
   tgt
   irqbalance

Relocated packages:
   base/
      dhcp
      initscripts
      libevent
      lighttpd
      linuxptp
      memcached
      net-snmp
      novnc
      ntp
      openssh
      pam
      procps
      sanlock
      shadow
      sudo
      systemd
      util-linux
      vim
      watchdog

   ceph/
      python-cephclient

   config/
      facter
      puppet-4.8.2
      puppet-modules

   filesystem/
      e2fsprogs
      nfs-utils
      nfscheck

   kernel/
      kernel-std
      kernel-rt

   kernel/kernel-modules/
      mlnx-ofa_kernel

   ldap/
      nss-pam-ldapd
      openldap

   logging/
      syslog-ng
      logrotate

   networking/
      lldpd
      iproute
      mellanox
      python-ryu
      mlx4-config

   python/
      python-2.7.5
      python-django
      python-gunicorn
      python-setuptools
      python-smartpm
      python-voluptuous

   security/
      shim-signed
      shim-unsigned
      tboot

   strorage-drivers/
      python-3parclient
      python-lefthandclient

   virt/
      cloud-init
      libvirt
      libvirt-python
      qemu

   tools/
      storage-topology
      vm-topology

   utilities/
      tis-extensions
      namespace-utils
      nova-utils
      update-motd

Change-Id: I37ade764d873c701b35eac5881eb40412ba64a86
Story: 2002801
Task: 22687
Signed-off-by: Scott Little <scott.little@windriver.com>
2018-08-01 10:06:31 -04:00

114 lines
5.0 KiB
Diff

From f22d4c9d24939afb8f29323adffe3eb570f14804 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=3D=3FUTF-8=3Fq=3FIgor=3D20Gali=3DC4=3D87=3F=3D?=
<i.galic@brainsware.org>
Date: Wed, 2 Nov 2016 14:54:28 -0400
Subject: [PATCH] fix "absent" options
analogous to redhat, we check if options are absent, before appending
them to the file. This fixes #160
Signed-off-by: Allain Legacy <allain.legacy@windriver.com>
---
.../lib/puppet/provider/network_route/redhat.rb | 10 ++---
.../lib/puppet/provider/network_route/routes.rb | 3 +-
.../unit/provider/network_route/routes_spec.rb | 48 ++++++++++++++++++++++
3 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/packstack/puppet/modules/network/lib/puppet/provider/network_route/redhat.rb b/packstack/puppet/modules/network/lib/puppet/provider/network_route/redhat.rb
index 9841c8e..7123d44 100644
--- a/packstack/puppet/modules/network/lib/puppet/provider/network_route/redhat.rb
+++ b/packstack/puppet/modules/network/lib/puppet/provider/network_route/redhat.rb
@@ -84,15 +84,11 @@ Puppet::Type.type(:network_route).provide(:redhat) do
raise Puppet::Error, "#{provider.name} does not have a #{prop}." if provider.send(prop).nil?
end
if provider.network == "default"
- contents << "#{provider.network} via #{provider.gateway} dev #{provider.interface}\n"
+ contents << "#{provider.network} via #{provider.gateway} dev #{provider.interface}"
else
- contents << "#{provider.network}/#{provider.netmask} via #{provider.gateway} dev #{provider.interface}\n"
+ contents << "#{provider.network}/#{provider.netmask} via #{provider.gateway} dev #{provider.interface}"
end
- contents << if provider.options == :absent
- "\n"
- else
- " #{provider.options}\n"
- end
+ contents << (provider.options == :absent ? "\n" : " #{provider.options}\n")
end
contents.join
end
diff --git a/packstack/puppet/modules/network/lib/puppet/provider/network_route/routes.rb b/packstack/puppet/modules/network/lib/puppet/provider/network_route/routes.rb
index 2dd579f..ca7066d 100644
--- a/packstack/puppet/modules/network/lib/puppet/provider/network_route/routes.rb
+++ b/packstack/puppet/modules/network/lib/puppet/provider/network_route/routes.rb
@@ -93,7 +93,8 @@ Puppet::Type.type(:network_route).provide(:routes) do
raise Puppet::Error, "#{provider.name} is missing the required parameter 'gateway'." if provider.gateway.nil?
raise Puppet::Error, "#{provider.name} is missing the required parameter 'interface'." if provider.interface.nil?
- contents << "#{provider.network} #{provider.netmask} #{provider.gateway} #{provider.interface} #{provider.options}\n"
+ contents << "#{provider.network} #{provider.netmask} #{provider.gateway} #{provider.interface}"
+ contents << (provider.options == :absent ? "\n" : " #{provider.options}\n")
end
contents.join
diff --git a/packstack/puppet/modules/network/spec/unit/provider/network_route/routes_spec.rb b/packstack/puppet/modules/network/spec/unit/provider/network_route/routes_spec.rb
index 2e55eba..9376739 100644
--- a/packstack/puppet/modules/network/spec/unit/provider/network_route/routes_spec.rb
+++ b/packstack/puppet/modules/network/spec/unit/provider/network_route/routes_spec.rb
@@ -93,4 +93,52 @@ describe Puppet::Type.type(:network_route).provider(:routes) do
end
end
end
+ describe 'when formatting simple files' do
+ let(:route1_provider) do
+ stub('route1_provider',
+ name: '172.17.67.0',
+ network: '172.17.67.0',
+ netmask: '255.255.255.0',
+ gateway: '172.18.6.2',
+ interface: 'vlan200',
+ options: :absent,
+ )
+ end
+
+ let(:route2_provider) do
+ stub('lo_provider',
+ name: '172.28.45.0',
+ network: '172.28.45.0',
+ netmask: '255.255.255.0',
+ gateway: '172.18.6.2',
+ interface: 'eth0',
+ options: :absent,
+ )
+ end
+
+ let(:content) { described_class.format_file('', [route1_provider, route2_provider]) }
+
+ describe 'writing the route line' do
+ it 'should write only fields' do
+ expect(content.scan(/^172.17.67.0 .*$/).length).to eq(1)
+ expect(content.scan(/^172.17.67.0 .*$/).first.split(/\s/, 5).length).to eq(4)
+ end
+
+ it 'should have the correct fields appended' do
+ expect(content.scan(/^172.17.67.0 .*$/).first).to include('172.17.67.0 255.255.255.0 172.18.6.2 vlan200')
+ end
+
+ it 'should fail if the netmask property is not defined' do
+ route2_provider.unstub(:netmask)
+ route2_provider.stubs(:netmask).returns nil
+ expect { content }.to raise_exception
+ end
+
+ it 'should fail if the gateway property is not defined' do
+ route2_provider.unstub(:gateway)
+ route2_provider.stubs(:gateway).returns nil
+ expect { content }.to raise_exception
+ end
+ end
+ end
end
--
1.8.3.1