* (#3) Add a new fact to calculate venet's network with /24 instead of /32.
This commit is contained in:
parent
a9c7d2e1aa
commit
8f86e8cac2
|
@ -6,7 +6,8 @@
|
||||||
* (#2) Add an array and a file to load additionnal modules.
|
* (#2) Add an array and a file to load additionnal modules.
|
||||||
* Correct module's dependencies.
|
* Correct module's dependencies.
|
||||||
* (#9) Add a puppetlabs-firewall rule.
|
* (#9) Add a puppetlabs-firewall rule.
|
||||||
* (#3) Add a new class and subclass: proxmox::vm::openvz to manage OpenVZ CT
|
* (#3) Add a new class and subclass: proxmox::vm::openvz to manage OpenVZ CT.
|
||||||
|
* (#3) Add a new fact to calculate venet's network with /24 instead of /32.
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
# Fact: vznetwork
|
||||||
|
#
|
||||||
|
# Purpose:
|
||||||
|
# Get networks for Virtual Network aka venet in OpenVZ CT, for available
|
||||||
|
# network networks
|
||||||
|
#
|
||||||
|
# Resolution:
|
||||||
|
# Uses `facter/util/ip` to enumerate interfaces and return their information.
|
||||||
|
#
|
||||||
|
require 'facter/util/ip'
|
||||||
|
require 'ipaddr'
|
||||||
|
|
||||||
|
Facter::Util::IP.get_interfaces.each do |interface|
|
||||||
|
Facter.add("vznetwork_" + Facter::Util::IP.alphafy(interface)) do
|
||||||
|
setcode do
|
||||||
|
if interface =~ /^venet*/
|
||||||
|
|
||||||
|
ipaddress = Facter::Util::IP.get_interface_value(interface, "ipaddress")
|
||||||
|
netmask = Facter::Util::IP.get_interface_value(interface, "netmask")
|
||||||
|
if netmask == "255.255.255.255"
|
||||||
|
# It's not possible to modify the netmask from WebGUI, so it's mainly set to /32
|
||||||
|
# http://openvz.org/Venet#Adding_IP_address_to_a_container
|
||||||
|
netmask = "255.255.255.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
if ipaddress && netmask
|
||||||
|
ip = IPAddr.new(ipaddress, Socket::AF_INET)
|
||||||
|
subnet = IPAddr.new(netmask, Socket::AF_INET)
|
||||||
|
ip.mask(subnet.to_s).to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,6 +10,6 @@ iface eth0 inet dhcp
|
||||||
# <%= scope.lookupvar('::ipaddress_eth0') %>
|
# <%= scope.lookupvar('::ipaddress_eth0') %>
|
||||||
up ip route add default dev eth0
|
up ip route add default dev eth0
|
||||||
up ip route add <%= scope.lookupvar('::network_eth0') %>/<%= scope.lookupvar('::netmask_eth0') %> dev eth0 protocol kernel src <%= scope.lookupvar('::ipaddress_eth0') %>
|
up ip route add <%= scope.lookupvar('::network_eth0') %>/<%= scope.lookupvar('::netmask_eth0') %> dev eth0 protocol kernel src <%= scope.lookupvar('::ipaddress_eth0') %>
|
||||||
up ip route add <%= scope.lookupvar('::network_venet0_0') %>/<%= scope.lookupvar('::netmask_venet0_0') %> dev venet0
|
up ip route add <%= scope.lookupvar('::vznetwork_venet0_0') %>/<%= scope.lookupvar('::netmask_venet0_0') %> dev venet0
|
||||||
down ip route del default dev eth0
|
down ip route del default dev eth0
|
||||||
down ip route del <%= scope.lookupvar('::network_venet0_0') %>/<%= scope.lookupvar('::netmask_venet0_0') %> dev venet0
|
down ip route del <%= scope.lookupvar('::vznetwork_venet0_0') %>/<%= scope.lookupvar('::netmask_venet0_0') %> dev venet0
|
||||||
|
|
Loading…
Reference in New Issue