B #3189: Specific reboot cycle for LXd. Network Hook to remove links for LXD

This commit is contained in:
Daniel Clavijo Coca authored and Ruben S. Montero committed 2019-10-02 15:24:18 +02:00
1 parent 0fb9f536df
commit a4e0eee4fb
8 files changed
+154 -68

No files matched your search

+10
View File
@@ -515,13 +515,21 @@ INSTALL_FILES=(
NETWORK_FILES:$VAR_LOCATION/remotes/vnm
NETWORK_ETC_FILES:$VAR_LOCATION/remotes/etc/vnm
NETWORK_8021Q_FILES:$VAR_LOCATION/remotes/vnm/802.1Q
NETWORK_LXD_FILES:$VAR_LOCATION/remotes/vnm/802.1Q/clean.d
NETWORK_VXLAN_FILES:$VAR_LOCATION/remotes/vnm/vxlan
NETWORK_LXD_FILES:$VAR_LOCATION/remotes/vnm/vxlan/clean.d
NETWORK_DUMMY_FILES:$VAR_LOCATION/remotes/vnm/dummy
NETWORK_LXD_FILES:$VAR_LOCATION/remotes/vnm/dummy/clean.d
NETWORK_BRIDGE_FILES:$VAR_LOCATION/remotes/vnm/bridge
NETWORK_LXD_FILES:$VAR_LOCATION/remotes/vnm/bridge/clean.d
NETWORK_EBTABLES_FILES:$VAR_LOCATION/remotes/vnm/ebtables
NETWORK_LXD_FILES:$VAR_LOCATION/remotes/vnm/ebtables/clean.d
NETWORK_FW_FILES:$VAR_LOCATION/remotes/vnm/fw
NETWORK_LXD_FILES:$VAR_LOCATION/remotes/vnm/fw/clean.d
NETWORK_OVSWITCH_FILES:$VAR_LOCATION/remotes/vnm/ovswitch
NETWORK_LXD_FILES:$VAR_LOCATION/remotes/vnm/ovswitch/clean.d
NETWORK_OVSWITCH_VXLAN_FILES:$VAR_LOCATION/remotes/vnm/ovswitch_vxlan
NETWORK_LXD_FILES:$VAR_LOCATION/remotes/vnm/ovswitch_vxlan/clean.d
NETWORK_VCENTER_FILES:$VAR_LOCATION/remotes/vnm/vcenter
NETWORK_ALIAS_SDNAT_FILES:$VAR_LOCATION/remotes/vnm/alias_sdnat
EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples
@@ -1194,6 +1202,8 @@ NETWORK_ALIAS_SDNAT_FILES="src/vnm_mad/remotes/alias_sdnat/AliasSDNAT.rb \
src/vnm_mad/remotes/alias_sdnat/pre \
src/vnm_mad/remotes/alias_sdnat/update_sg "
NETWORK_LXD_FILES="src/vnm_mad/remotes/lib/lxd_clean.rb"
#-------------------------------------------------------------------------------
# Virtual Network Manager drivers configuration to be installed under $REMOTES_LOCATION/etc/vnm
#-------------------------------------------------------------------------------
+91 -61
View File
@@ -233,7 +233,7 @@ class VmmAction
result, info = vnm.do_action(@id, step[:action],
:parameters => params)
when :tm
result, info = @tm.do_transfer_action(@id, step[:parameters], stdin=step[:stdin])
result, info = @tm.do_transfer_action(@id, step[:parameters], stdin = step[:stdin])
else
result = DriverExecHelper.const_get(:RESULT)[:failure]
@@ -396,32 +396,32 @@ class ExecDriver < VirtualMachineDriver
end
steps.concat([
# Execute pre-boot networking setup
{
:driver => :vnm,
:action => :pre
},
# Boot the Virtual Machine
{
:driver => :vmm,
:action => :deploy,
:parameters => [dfile, :host],
:stdin => domain
},
# Execute post-boot networking setup
{
:driver => :vnm,
:action => :post,
:parameters => [:deploy_info],
:fail_actions => [
{
:driver => :vmm,
:action => :cancel,
:parameters => [:deploy_info, :host]
}
]
}
])
# Execute pre-boot networking setup
{
:driver => :vnm,
:action => :pre
},
# Boot the Virtual Machine
{
:driver => :vmm,
:action => :deploy,
:parameters => [dfile, :host],
:stdin => domain
},
# Execute post-boot networking setup
{
:driver => :vnm,
:action => :post,
:parameters => [:deploy_info],
:fail_actions => [
{
:driver => :vmm,
:action => :cancel,
:parameters => [:deploy_info, :host]
}
]
}
])
action.run(steps)
end
@@ -485,31 +485,31 @@ class ExecDriver < VirtualMachineDriver
action = VmmAction.new(self, id, :restore, drv_message)
steps.concat([
# Execute pre-boot networking setup
{
:driver => :vnm,
:action => :pre
},
# Restore the Virtual Machine from checkpoint
{
:driver => :vmm,
:action => :restore,
:parameters => [:checkpoint_file, :host, :deploy_id]
},
# Execute post-boot networking setup
{
:driver => :vnm,
:action => :post,
:parameters => [:deploy_id],
:fail_actions => [
{
:driver => :vmm,
:action => :cancel,
:parameters => [:deploy_id, :host]
}
]
}
])
# Execute pre-boot networking setup
{
:driver => :vnm,
:action => :pre
},
# Restore the Virtual Machine from checkpoint
{
:driver => :vmm,
:action => :restore,
:parameters => [:checkpoint_file, :host, :deploy_id]
},
# Execute post-boot networking setup
{
:driver => :vnm,
:action => :post,
:parameters => [:deploy_id],
:fail_actions => [
{
:driver => :vmm,
:action => :cancel,
:parameters => [:deploy_id, :host]
}
]
}
])
action.run(steps)
end
@@ -599,9 +599,7 @@ class ExecDriver < VirtualMachineDriver
:stdin => xml_data)
end
#
# REBOOT action, reboots a running VM
#
def reboot(id, drv_message)
restart(id, drv_message, :reboot)
end
@@ -1104,8 +1102,8 @@ class ExecDriver < VirtualMachineDriver
# Get TM command
tm_command = ensure_xpath(xml_data, id, action, 'TM_COMMAND') || return
tm_command_split = tm_command.split
tm_command_split[0].sub!('.', '_LIVE.') or tm_command_split[0] += '_LIVE'
tm_command_split = tm_command.split
tm_command_split[0].sub!('.', '_LIVE.') || (tm_command_split[0] += '_LIVE')
action = VmmAction.new(self, id, :disk_snapshot_create, drv_message)
@@ -1183,6 +1181,7 @@ class ExecDriver < VirtualMachineDriver
action.run(steps, sg_id)
end
private
def ensure_xpath(xml_data, id, action, xpath)
@@ -1197,12 +1196,43 @@ class ExecDriver < VirtualMachineDriver
end
def restart(id, drv_message, signal)
data = decode(drv_message)
host = data.elements['HOST'].text
deploy_id = data.elements['DEPLOY_ID'].text
action = VmmAction.new(self, id, signal, drv_message)
do_action("#{deploy_id} #{host}", id, host, ACTION[signal],
:stdin => data)
reboot_step = {
:driver => :vmm,
:action => signal,
:parameters => [:deploy_id, :host]
}
steps = [reboot_step]
if @hypervisor == 'lxd'
steps += [
{
:driver => :vnm,
:action => :clean
},
{
:driver => :vnm,
:action => :pre
},
reboot_step,
{
:driver => :vnm,
:action => :post,
:parameters => [:deploy_info],
:fail_actions => [
{
:driver => :vmm,
:action => :cancel,
:parameters => [:deploy_info, :host]
}
]
}
]
end
action.run(steps)
end
def destroy(id, drv_message, signal)
+2 -2
View File
@@ -225,11 +225,11 @@ class Container
end
end
def check_stop
def check_stop(force)
return if status != 'Running'
begin
if ARGV[-1] == '-f'
if force == '-f'
stop(:force => true)
else
stop
+1 -1
View File
@@ -16,4 +16,4 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
$(dirname $0)/shutdown $@ '-f'
$(dirname $0)/shutdown "$@" '-f'
+12 -2
View File
@@ -34,5 +34,15 @@ container = Container.get(vm_name, container.config['user.xml'], client)
# ------------------------------------------------------------------------------
# Stop the container, start it
# ------------------------------------------------------------------------------
container.check_stop
container.start
case container.config['user.reboot_state']
when 'STOPPED'
container.start
container.config['user.reboot_state'] = 'RUNNING'
else
force = false
force = true if ARGV[-1] == '-f'
container.check_stop(force)
container.config['user.reboot_state'] = 'STOPPED'
end
container.update
+1 -1
View File
@@ -16,4 +16,4 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
$(dirname $0)/reboot $1 '-f'
$(dirname $0)/reboot "$@" '-f'
+4 -1
View File
@@ -37,7 +37,10 @@ container = Container.get(vm_name, xml, client)
# Stop vnc connection and container & unmap devices if not a wild container
# ------------------------------------------------------------------------------
container.vnc('stop')
container.check_stop
force = false
force = true if ARGV[-1] == '-f'
container.check_stop(force)
exit 0 if container.wild?
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/ruby
$LOAD_PATH << "#{__dir__}/../.."
require 'vnmmad'
require 'open3'
template64 = STDIN.read
vnm = VNMMAD::NoVLANDriver.from_base64(template64, nil, nil)
vm = vnm.vm
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