Sha256: 74f2b2fbd06c2656510e5a778abfd654098a062678030d2d7f68c081442374c2

Contents?: true

Size: 1.35 KB

Versions: 6

Compression:

Stored size: 1.35 KB

Contents

def load_current_resource
  @lxc = ::Lxc.new(
    new_resource.container,
    :base_dir => node[:lxc][:container_directory],
    :dnsmasq_lease_file => node[:lxc][:dnsmasq_lease_file]
  )
  @loaded ||= {}
  # value checks
  unless(new_resource.dynamic)
    %w(address netmask).each do |key|
      raise "#{key} is required for static interfaces" if new_resource.send(key).nil?
    end
  end
  node.run_state[:lxc] ||= Mash.new
  node.run_state[:lxc][:interfaces] ||= Mash.new
  node.run_state[:lxc][:interfaces][new_resource.container] ||= []
end

action :create do
  raise 'Device is required for creating an LXC interface!' unless new_resource.device
  
  unless(@loaded[new_resource.container])
    @loaded[new_resource.container] = true
  end

  net_set = Mash.new(:device => new_resource.device)
  if(new_resource.dynamic)
    net_set[:dynamic] = true
  else
    net_set[:auto] = new_resource.auto
    net_set[:address] = new_resource.address
    net_set[:gateway] = new_resource.gateway
    net_set[:netmask] = new_resource.netmask
    net_set[:up] = new_resource.up if new_resource.up
    net_set[:down] = new_resource.down if new_resource.down
    net_set[:ipv6] = new_resource.ipv6
  end

  node.run_state[:lxc][:interfaces][new_resource.container] << net_set
end

action :delete do
  # do nothing, simply not provided to run_state, and thus implicitly
  # deleted
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
vagabond-0.2.8 lib/vagabond/cookbooks/lxc/providers/interface.rb
vagabond-0.2.6 lib/vagabond/cookbooks/lxc/providers/interface.rb
vagabond-0.2.4 lib/vagabond/cookbooks/lxc/providers/interface.rb
vagabond-0.2.2 lib/vagabond/cookbooks/lxc/providers/interface.rb
elecksee-1.0.2 lib/elecksee/vendor/lxc/providers/interface.rb
elecksee-1.0.0 lib/elecksee/vendor/lxc/providers/interface.rb