Class: Construqt::Flavour::Ubuntu::Services::DhcpV4Relay
- Inherits:
-
Object
- Object
- Construqt::Flavour::Ubuntu::Services::DhcpV4Relay
- Defined in:
- lib/construqt/flavour/ubuntu/flavour_ubuntu_services.rb
Instance Method Summary collapse
- #down(ifname, inbounds, upstreams) ⇒ Object
-
#initialize(service) ⇒ DhcpV4Relay
constructor
A new instance of DhcpV4Relay.
- #interfaces(host, ifname, iface, writer) ⇒ Object
- #up(ifname, inbounds, upstreams) ⇒ Object
- #vrrp(host, ifname, vrrp) ⇒ Object
Constructor Details
#initialize(service) ⇒ DhcpV4Relay
Returns a new instance of DhcpV4Relay.
7 8 9 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_services.rb', line 7 def initialize(service) @service = service end |
Instance Method Details
#down(ifname, inbounds, upstreams) ⇒ Object
18 19 20 21 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_services.rb', line 18 def down(ifname, inbounds, upstreams) #"kill `cat /run/dhcrelay-v4.#{ifname}.pid`" "kill `cat /run/dhcp-helper-v4.#{ifname}.pid`" end |
#interfaces(host, ifname, iface, writer) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_services.rb', line 35 def interfaces(host, ifname, iface, writer) inbounds = Construqt::Tags.find(@service.inbound_tag).select{ |cqip| cqip.container.interface.host == host && cqip.ipv4? } return if inbounds.empty? upstreams = Construqt::Tags.find(@service.upstream_tag).select{ |cqip| cqip.ipv4? } return if upstreams.empty? writer.lines.up(up(ifname, inbounds, upstreams)) writer.lines.down(down(ifname, inbounds, upstreams)) host.result.add_component(Construqt::Resources::Component::DHCPRELAY) end |
#up(ifname, inbounds, upstreams) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_services.rb', line 11 def up(ifname, inbounds, upstreams) minus_i = (inbounds.map { |cqip| "-i #{cqip.container.interface.name}" }).join(' ') servers = upstreams.map{ |cqip| "-s #{cqip.to_s}" }.join(' ') #"/usr/sbin/dhcrelay -pf /run/dhcrelay-v4.#{ifname}.pid -q -4 #{minus_i} #{servers}" "/usr/sbin/dhcp-helper #{servers} #{minus_i} -r /run/dhcp-helper-v4.#{ifname}.pid" end |
#vrrp(host, ifname, vrrp) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_services.rb', line 23 def vrrp(host, ifname, vrrp) inbounds = Construqt::Tags.find(@service.inbound_tag).select{ |cqip| cqip.container.interface.host == host && cqip.ipv4? && !cqip.container.interface.name.empty? } return if inbounds.empty? iface = vrrp.interfaces.find{|_| _.host == host } return unless iface upstreams = Construqt::Tags.find(@service.upstream_tag).select{ |cqip| cqip.ipv4? } return if upstreams.empty? host.result.etc_network_vrrp(vrrp.name).add_master(up(ifname, inbounds, upstreams)) .add_backup(down(ifname, inbounds, upstreams)) host.result.add_component(Construqt::Resources::Component::DHCPRELAY) end |