Skip to content

Commit

Permalink
B #3189: Beta LXD post net cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dann1 committed Aug 21, 2019
1 parent 9812a9a commit b098a91
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/vnm_mad/remotes/lib/lxd_clean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,31 @@
$LOAD_PATH << "#{__dir__}/../.."

require 'vnmmad'
require 'open3'

template64 = STDIN.read
vnm = VNMMAD::NoVLANDriver.from_base64(template64, nil, nil)

exit 0 unless vnm.vm.hypervisor == 'lxd'
STDERR.puts 'running lxd nic clean hook'
vm = vnm.vm

exit 0
exit 0 unless vm.hypervisor == 'lxd'
OpenNebula.log 'running lxd network post cleanup'

vm.nics.each do |nic|
next unless nic[:nic]

veth = nic[:nic][:target]

cmd = "ip link show #{veth}"

_o, _e, s = Open3.capture3(cmd)

next unless s == 0

cmd = "ip link delete #{veth}"
OpenNebula.log "Found lingering nic #{veth}\n Running #{cmd}"

o, e, _s = Open3.capture3(cmd)

OpenNebula.log "#{o}\n#{e}"
end

0 comments on commit b098a91

Please sign in to comment.