diff --git a/.pdkignore b/.pdkignore index 584438f..862847a 100644 --- a/.pdkignore +++ b/.pdkignore @@ -29,6 +29,7 @@ /.fixtures.yml /Gemfile /.gitattributes +/.github/ /.gitignore /.pdkignore /.puppet-lint.rc diff --git a/Gemfile b/Gemfile index 4a398ec..7da283c 100644 --- a/Gemfile +++ b/Gemfile @@ -34,6 +34,7 @@ group :development do gem "rubocop", '= 1.48.1', require: false gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false + gem "puppet-strings", '~> 4.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "puppet-blacksmith", require: false gem "github_changelog_generator", require: false @@ -43,6 +44,10 @@ group :system_tests do gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] gem "serverspec", '~> 2.41', require: false end +group :release_prep do + gem "puppet-strings", '~> 4.0', require: false + gem "puppetlabs_spec_helper", '~> 6.0', require: false +end puppet_version = ENV['PUPPET_GEM_VERSION'] facter_version = ENV['FACTER_GEM_VERSION'] diff --git a/lib/puppet/provider/libvirt_network/virsh.rb b/lib/puppet/provider/libvirt_network/virsh.rb index 41a298c..7988f72 100644 --- a/lib/puppet/provider/libvirt_network/virsh.rb +++ b/lib/puppet/provider/libvirt_network/virsh.rb @@ -96,7 +96,16 @@ def content formatter = REXML::Formatters::Pretty.new(2) formatter.compact = true output = ''.dup - formatter.write(recursive_sort(xml.root), output) + + xml = recursive_sort(xml.root) + sorted_portgroups = xml.root.get_elements('//portgroup').sort_by { |obj| obj.attributes['name'] } + + REXML::XPath.match(xml, '//portgroup').each(&:remove) + sorted_portgroups.each do |pg| + xml.root.add_element pg + end + + formatter.write(xml.root, output) output end diff --git a/lib/puppet/type/libvirt_network.rb b/lib/puppet/type/libvirt_network.rb index a8f123c..57a0c99 100644 --- a/lib/puppet/type/libvirt_network.rb +++ b/lib/puppet/type/libvirt_network.rb @@ -46,6 +46,22 @@ raise ArgumentError, 'content needs to be a XML string' unless value.is_a?(String) end + def change_to_s(current, desire) + if @resource[:show_diff] + current_exp = Tempfile.new('current', '/tmp').open + current_exp.write(current.to_s) + current_exp.close + current_path = current_exp.path + desire_exp = Tempfile.new('desire', '/tmp').open + desire_exp.write(desire.to_s) + desire_exp.close + desire_path = desire_exp.path + system "diff -u #{current_path} #{desire_path}" + else + '{md5}' + Digest::MD5.hexdigest(current.to_s) + ' to: ' + '{md5}' + Digest::MD5.hexdigest(desire.to_s) + end + end + def should_to_s(value) if @resource[:show_diff] ":\n" + value + "\n" diff --git a/metadata.json b/metadata.json index 5fc0485..98a409a 100644 --- a/metadata.json +++ b/metadata.json @@ -69,7 +69,7 @@ "drbd", "virtualization" ], - "pdk-version": "3.0.0", - "template-url": "pdk-default#3.0.0", - "template-ref": "tags/3.0.0-0-g056e50d" + "pdk-version": "3.0.1", + "template-url": "pdk-default#3.0.1", + "template-ref": "tags/3.0.1-0-gd13288a" } diff --git a/spec/default_facts.yml b/spec/default_facts.yml index f777abf..3346c39 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -2,7 +2,8 @@ # # Facts specified here will override the values provided by rspec-puppet-facts. --- -ipaddress: "172.16.254.254" -ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" +networking: + ip: "172.16.254.254" + ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" + mac: "AA:AA:AA:AA:AA:AA" is_pe: false -macaddress: "AA:AA:AA:AA:AA:AA"