lib/dev-lxc.rb in dev-lxc-0.6.4 vs lib/dev-lxc.rb in dev-lxc-1.0.0
- old
+ new
@@ -4,17 +4,17 @@
require "dev-lxc/container"
require "dev-lxc/server"
require "dev-lxc/cluster"
module DevLXC
- def self.create_platform_image(platform_image_name)
- platform_image = DevLXC::Container.new(platform_image_name)
+ def self.create_platform_image(platform_image_name, lxc_config_path='/var/lib/lxc')
+ platform_image = DevLXC::Container.new(platform_image_name, lxc_config_path)
if platform_image.defined?
- puts "Using existing platform image #{platform_image.name}"
+ puts "Using existing platform image '#{platform_image.name}'"
return platform_image
end
- puts "Creating platform image #{platform_image.name}"
+ puts "Creating platform image '#{platform_image.name}'"
case platform_image.name
when "p-ubuntu-1004"
platform_image.create("download", "btrfs", {}, 0, ["-d", "ubuntu", "-r", "lucid", "-a", "amd64"])
when "p-ubuntu-1204"
platform_image.create("download", "btrfs", {}, 0, ["-d", "ubuntu", "-r", "precise", "-a", "amd64"])
@@ -27,15 +27,15 @@
end
unless platform_image.config_item("lxc.mount.auto").nil?
platform_image.set_config_item("lxc.mount.auto", "proc:rw sys:rw")
end
hwaddr = '00:16:3e:' + Digest::SHA1.hexdigest(Time.now.to_s).slice(0..5).unpack('a2a2a2').join(':')
- puts "Setting #{platform_image.name} platform image's lxc.network.0.hwaddr to #{hwaddr}"
+ puts "Setting '#{platform_image.name}' platform image's lxc.network.0.hwaddr to #{hwaddr}"
platform_image.set_config_item("lxc.network.0.hwaddr", hwaddr)
platform_image.save_config
platform_image.start
- puts "Installing packages in platform image #{platform_image.name}"
+ puts "Installing packages in platform image '#{platform_image.name}'"
case platform_image.name
when "p-ubuntu-1004"
# Disable certain sysctl.d files in Ubuntu 10.04, they cause `start procps` to fail
if File.exist?("#{platform_image.config_item('lxc.rootfs')}/etc/sysctl.d/10-console-messages.conf")
FileUtils.mv("#{platform_image.config_item('lxc.rootfs')}/etc/sysctl.d/10-console-messages.conf",
@@ -57,10 +57,10 @@
platform_image.stop
return platform_image
end
def self.assign_ip_address(ipaddress, container_name, hwaddr)
- puts "Assigning IP address #{ipaddress} to #{container_name} container's lxc.network.hwaddr #{hwaddr}"
+ puts "Assigning IP address #{ipaddress} to '#{container_name}' container's lxc.network.hwaddr #{hwaddr}"
search_file_delete_line("/etc/lxc/dhcp-hosts.conf", /(^#{hwaddr}|,#{ipaddress}$)/)
append_line_to_file("/etc/lxc/dhcp-hosts.conf", "#{hwaddr},#{ipaddress}\n")
reload_dnsmasq
end