Sha256: 71af6af41d6408c504244592688630950134b39da8655aaf0fa266c86dfbc34e

Contents?: true

Size: 1.45 KB

Versions: 6

Compression:

Stored size: 1.45 KB

Contents

use_inline_resources if self.respond_to?(:use_inline_resources)

def load_current_resource
  @lxc = ::Lxc.new(
    new_resource.base_container,
    :base_dir => node[:lxc][:container_directory],
    :dnsmasq_lease_file => node[:lxc][:dnsmasq_lease_file]
  )
  unless(@lxc.exists?)
    raise "Requested base contianer: #{new_resource.base_container} does not exist"
  end
  @start_script = node[:lxc][:awesome_ephemerals] ? '/usr/local/bin/lxc-awesome-ephemeral' : 'lxc-ephemeral-start'
  unless(node[:lxc][:awesome_ephemerals])
    %w(host_rootfs virtual_device).each do |key|
      if(resource.send(key))
        raise "#{key} lxc ephemeral attribute only valid when awesome_ephemerals is true!"
      end
    end
  end
end

action :run do
  com = [@start_script]
  com << "-o #{new_resource.base_container}"
  com << "-b #{new_resource.bind_directory}" if new_resource.bind_directory
  com << "-U #{new_resource.union_type}"
  com << "-u #{new_resource.user}"
  com << "-S #{new_resource.key}"
  com << "-z #{new_resource.host_rootfs}" if new_resource.host_rootfs
  com << "-D #{new_resource.virtual_device}" if new_resource.virtual_device 
  if(new_resource.background)
    Chef::Log.warn("Ephemeral container will be backgrounded: #{new_resource.name}")
    com << '-d'
  end
  com << "\"#{new_resource.command}\"" # TODO: fix this to be proper
  execute "LXC ephemeral: #{new_resource.name}" do
    command com.join(' ')
    stream_output new_resource.stream_output
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

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