Class: Construqt::Flavour::Ubuntu::Services::DhcpV6Relay

Inherits:
Object
  • Object
show all
Defined in:
lib/construqt/flavour/ubuntu/flavour_ubuntu_services.rb

Instance Method Summary collapse

Constructor Details

#initialize(service) ⇒ DhcpV6Relay

Returns a new instance of DhcpV6Relay.



33
34
35
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_services.rb', line 33

def initialize(service)
  @service = service
end

Instance Method Details

#down(iface, ifname) ⇒ Object



41
42
43
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_services.rb', line 41

def down(iface, ifname)
  "kill `cat /run/dhcrelay-v6.#{ifname}.pid`"
end

#interfaces(host, ifname, iface, writer) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_services.rb', line 49

def interfaces(host, ifname, iface, writer)
  return unless iface.address && iface.address.first_ipv6
  return if @service.servers.empty?
  @service.servers.each do |server|
    unless @service.services.region.interfaces.find(host, server.iface)
      throw "DhcpV6Relay interface with name #{service.iface} not found on #{host.name}"
    end
  end
  writer.lines.up(up(iface, ifname))
  writer.lines.down(down(iface, ifname))
end

#up(iface, ifname) ⇒ Object



37
38
39
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_services.rb', line 37

def up(iface, ifname)
  "/usr/sbin/dhcrelay -pf /run/dhcrelay-v6.#{ifname}.pid -q -6 -l #{iface.address.first_ipv6.to_s}%#{ifname} #{@service.servers.map{|i| "-u #{i.ip}%#{i.iface}" }.join(' ')}"
end

#vrrp(host, ifname, iface) ⇒ Object



45
46
47
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_services.rb', line 45

def vrrp(host, ifname, iface)
  host.result.etc_network_vrrp(iface.name).add_master(up(iface, ifname)).add_backup(down(iface, ifname))
end