From eb9b4789517027e26483c6767baa345823fafa5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Fri, 9 Aug 2019 17:23:46 +0200 Subject: [PATCH] Add ipv6 network config templates for SUSE based distributions --- templates/guests/suse/network_static6.erb | 16 +++++++ .../guests/suse/network_static6_test.rb | 43 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 templates/guests/suse/network_static6.erb create mode 100644 test/unit/templates/guests/suse/network_static6_test.rb diff --git a/templates/guests/suse/network_static6.erb b/templates/guests/suse/network_static6.erb new file mode 100644 index 000000000..94aff1fef --- /dev/null +++ b/templates/guests/suse/network_static6.erb @@ -0,0 +1,16 @@ +#VAGRANT-BEGIN +# The contents below are automatically generated by Vagrant. Do not modify. +STARTMODE='auto' +BOOTPROTO='static' +IPADDR=<%= options[:ip] %> +<% if options[:netmask] -%> +NETMASK=<%= options[:netmask] %> +<% end -%> +DEVICE=<%= options[:device] %> +<% if options[:gateway] -%> +GATEWAY=<%= options[:gateway] %> +<% end -%> +<% if options[:prefix_length] -%> +PREFIXLEN=<%= options[:prefix_length] %> +<% end -%> +#VAGRANT-END diff --git a/test/unit/templates/guests/suse/network_static6_test.rb b/test/unit/templates/guests/suse/network_static6_test.rb new file mode 100644 index 000000000..676de8223 --- /dev/null +++ b/test/unit/templates/guests/suse/network_static6_test.rb @@ -0,0 +1,43 @@ +require_relative "../../../base" + +require "vagrant/util/template_renderer" + +describe "templates/guests/suse/network_static6" do + let(:template) { "guests/suse/network_static6" } + + it "renders the template" do + result = Vagrant::Util::TemplateRenderer.render(template, options: { + device: "eth2", + ip: "fde4:8dba:82e1::c4", + }) + expect(result).to eq <<-EOH.gsub(/^ {6}/, "") + #VAGRANT-BEGIN + # The contents below are automatically generated by Vagrant. Do not modify. + STARTMODE='auto' + BOOTPROTO='static' + IPADDR=fde4:8dba:82e1::c4 + DEVICE=eth2 + #VAGRANT-END + EOH + end + + it "includes the prefix-length and gateway" do + result = Vagrant::Util::TemplateRenderer.render(template, options: { + device: "eth1", + ip: "fde4:8dba:82e1::c4", + gateway: "fde4:8dba:82e1::01", + prefix_length: "64", + }) + expect(result).to eq <<-EOH.gsub(/^ {6}/, "") + #VAGRANT-BEGIN + # The contents below are automatically generated by Vagrant. Do not modify. + STARTMODE='auto' + BOOTPROTO='static' + IPADDR=fde4:8dba:82e1::c4 + DEVICE=eth1 + GATEWAY=fde4:8dba:82e1::01 + PREFIXLEN=64 + #VAGRANT-END + EOH + end +end