lib/dev-lxc/server.rb in dev-lxc-1.5.0 vs lib/dev-lxc/server.rb in dev-lxc-1.5.1
- old
+ new
@@ -1,11 +1,11 @@
require "dev-lxc/container"
require "dev-lxc/cluster"
module DevLXC
class Server
- attr_reader :server, :platform_image_name, :shared_image_name
+ attr_reader :server, :platform_image_name, :platform_image_options, :shared_image_name
def initialize(name, server_type, cluster_config)
unless cluster_config[server_type]["servers"].keys.include?(name)
puts "ERROR: Server '#{name}' is not defined in the cluster config"
exit 1
@@ -24,10 +24,11 @@
@config = cluster_config[@server_type]["servers"][@server.name]
@ipaddress = @config["ipaddress"]
@role = @config["role"] ? @config["role"] : cluster_config[@server_type]['topology']
@mounts = cluster_config[@server_type]["mounts"]
@platform_image_name = cluster_config[@server_type]["platform_image"]
+ @platform_image_options = cluster_config[@server_type]["platform_image_options"]
@packages = cluster_config[@server_type]["packages"]
case @server_type
when 'adhoc'
@shared_image_name = ''
@@ -161,11 +162,11 @@
@server = DevLXC::Container.new(@server.name, @lxc_config_path)
return
else
puts "Creating container '#{@server.name}'"
if @server_type == 'adhoc'
- platform_image = DevLXC.create_platform_image(@platform_image_name, @lxc_config_path)
+ platform_image = DevLXC.create_platform_image(@platform_image_name, @platform_image_options, @lxc_config_path)
puts "Cloning platform image '#{platform_image.name}' into container '#{@server.name}'"
platform_image.clone(@server.name, {:flags => LXC::LXC_CLONE_SNAPSHOT})
else
unless @server.name == @chef_server_bootstrap_backend || DevLXC::Container.new(@chef_server_bootstrap_backend, @lxc_config_path).defined?
puts "ERROR: The bootstrap backend server '#{@chef_server_bootstrap_backend}' must be created first."
@@ -230,10 +231,10 @@
shared_image = DevLXC::Container.new(@shared_image_name, @lxc_config_path)
if shared_image.defined?
puts "Using existing shared image '#{shared_image.name}'"
return shared_image
end
- platform_image = DevLXC.create_platform_image(@platform_image_name, @lxc_config_path)
+ platform_image = DevLXC.create_platform_image(@platform_image_name, @platform_image_options, @lxc_config_path)
puts "Cloning platform image '#{platform_image.name}' into shared image '#{shared_image.name}'"
platform_image.clone(shared_image.name, {:flags => LXC::LXC_CLONE_SNAPSHOT})
shared_image = DevLXC::Container.new(shared_image.name, @lxc_config_path)
puts "Deleting SSH Server Host Keys"
FileUtils.rm_f(Dir.glob("#{shared_image.config_item('lxc.rootfs')}/etc/ssh/ssh_host*_key*"))