Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for path to ifcfg-eth0 on centos, to add 'BOOTPROTO=none' flag (dhcp) #18

Merged
merged 1 commit into from
Nov 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions lib/kitchen/driver/lxd_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LxdCli < Kitchen::Driver::Base
File.expand_path('~/.ssh/identity.pub'),
File.expand_path('~/.ssh/id_ecdsa.pub')
].find { |path| File.exist?(path) }

raise 'Public key could not be found in the public_key_path provided. Please update the kitchen-lxd_cli config public_key_path in kitchen yaml or create a ssh key pair (e.g. `ssh-keygen -t rsa`)' unless pub_key

pub_key
Expand Down Expand Up @@ -70,7 +70,7 @@ def create(state)
setup_ssh_access
wait_for_ssh_login(lxc_ip) if config[:enable_wait_for_ssh_login] == "true"
IO.popen("lxc exec #{@@instance_name} bash", "r+") do |p|
p.puts("if [ ! -d '#{config[:verifier_path]}' ]; then mkdir -p #{config[:verifier_path]}; fi")
p.puts("if [ ! -d '#{config[:verifier_path]}' ]; then mkdir -p #{config[:verifier_path]}; fi")
p.puts("if [ ! -L '/tmp/verifier' ]; then ln -s #{config[:verifier_path]} /tmp/verifier; fi")
end if config[:verifier_path] && config[:verifier_path].length > 0
end
Expand Down Expand Up @@ -134,9 +134,9 @@ def create_image_if_missing
unless image_exists?(image_name)
info("Creating image #{image_name} now.")
image = get_image_info
image_os = config[:image_os]
image_os = config[:image_os]
image_os ||= image[:os]
image_release = config[:image_release]
image_release = config[:image_release]
image_release ||= image[:release_num]
debug("Ran command: lxc image copy #{image_os}:#{image_release} local: --alias #{image_name}")
IO.popen("lxc image copy #{image_os}:#{image_release} local: --alias #{image_name}", "w") { |pipe| puts pipe.gets rescue nil }
Expand Down Expand Up @@ -185,7 +185,7 @@ def publish_image
def get_image_name
image_name = get_publish_image_name
unless config[:use_publish_image] == true && image_exists?(image_name)
image_name = config[:image_name]
image_name = config[:image_name]
image_name ||= instance.platform.name
end

Expand All @@ -211,8 +211,9 @@ def image_exists?(image_name)
return false
end
end

0
def config_and_start_container
platform, release = instance.platform.name.split('-')
config[:ip_gateway] ||= "auto"
arg_disable_dhcp = ""

Expand All @@ -221,7 +222,11 @@ def config_and_start_container
p.puts("echo -e \"lxc.network.0.ipv4 = #{config[:ipv4]}\nlxc.network.0.ipv4.gateway = #{config[:ip_gateway]}\n\" | lxc config set #{@@instance_name} raw.lxc -")
p.puts("exit")
end
arg_disable_dhcp = "&& lxc exec #{@@instance_name} -- sed -i 's/dhcp/manual/g' /etc/network/interfaces.d/eth0.cfg"
if platform.downcase == "ubuntu"
arg_disable_dhcp = "&& lxc exec #{@@instance_name} -- sed -i 's/dhcp/manual/g' /etc/network/interfaces.d/eth0.cfg"
elsif platform.downcase == "centos"
arg_disable_dhcp = "&& lxc exec #{@@instance_name} -- sed -i 's/dhcp/none/g' /etc/sysconfig/network-scripts/ifcfg-eth0"
end
end

info("Starting container #{@@instance_name}")
Expand Down Expand Up @@ -443,7 +448,7 @@ def debug_note_about_configuring_ip
debug("NOTE: Restarting seemed to be the only way I could get things to work. Tried lxc profiles, config options. Tried restart networking service but it didn't work, also tried passing command like ifconfig 10.0.3.x/24 eth0 up. Which set the ip but after container ran for a while, it would reset to dhcp address that had been assigned. Restarting container seems to be working, and is really fast. Open to better alternatives.")
end


=begin
def configure_ip_via_lxc_restart
debug("Configuring new ip address on eth0")
Expand Down
2 changes: 1 addition & 1 deletion lib/kitchen/driver/lxd_cli_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ module Kitchen
module Driver

# Version string for LxdCli Kitchen driver
LXD_CLI_VERSION = "2.0.1"
LXD_CLI_VERSION = "2.0.2"
end
end