Class: TestLab::Provisioner::Resolv

Inherits:
Object
  • Object
show all
Defined in:
lib/testlab/provisioners/resolv.rb

Overview

Resolv Provisioner Class

Author:

  • Zachary Patten <zachary AT jovelabs DOT com>

Instance Method Summary collapse

Constructor Details

#initialize(config = {}, ui = nil) ⇒ Resolv

Returns a new instance of Resolv.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/testlab/provisioners/resolv.rb', line 13

def initialize(config={}, ui=nil)
  @config = (config || Hash.new)
  @ui     = (ui     || TestLab.ui)

  @config[:resolv] ||= Hash.new

  @config[:resolv][:servers] ||= Array.new
  @config[:resolv][:servers].unshift([TestLab::Network.ips]).flatten!.compact!

  @config[:resolv][:search] ||= Array.new
  @config[:resolv][:search].unshift([TestLab::Container.domains]).flatten!.compact!

  @ui.logger.debug { "config(#{@config.inspect})" }
end

Instance Method Details

#on_container_provision(container) ⇒ Boolean Also known as: on_container_up

Resolv: Container Provision

Parameters:

Returns:

  • (Boolean)

    True if successful.



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/testlab/provisioners/resolv.rb', line 50

def on_container_provision(container)
  @ui.logger.debug { "RESOLV Provisioner: Container #{container.id}" }

  @config[:resolv].merge!(
    :object => :container
  )

  script = ZTK::Template.render(provision_template, @config)
  container.lxc.attach(%(-- /bin/bash -c '#{script}'))

  true
end

#on_node_provision(node) ⇒ Boolean

Resolv: Node Provision

Parameters:

Returns:

  • (Boolean)

    True if successful.



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/testlab/provisioners/resolv.rb', line 32

def on_node_provision(node)
  @ui.logger.debug { "RESOLV Provisioner: Node #{node.id}" }

  @config[:resolv].merge!(
    :servers => %w(127.0.0.1),
    :object => :node
  )

  node.bootstrap(ZTK::Template.render(provision_template, @config))

  true
end