1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

development: Additional LXD fixes. Minor refactor of check stop functionality

(cherry picked from commit 05258a1c9170e5fa4af474d0a271ef9235cfaaad)
This commit is contained in:
Daniel Clavijo Coca 2019-03-28 05:14:32 -06:00 committed by Ruben S. Montero
parent faa6688e2b
commit 7710d4eb9f
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
4 changed files with 16 additions and 15 deletions

View File

@ -69,7 +69,7 @@ class Container
@lxc = lxc
@one = one
@lxc_command = 'lxc'
@lxc_command.prepend 'sudo' if client.snap
@lxc_command.prepend 'sudo ' if client.snap
@containers = "#{@client.lxd_path}/storage-pools/default/containers"
@rootfs_dir = "#{@containers}/#{name}/rootfs"
@ -193,6 +193,16 @@ class Container
end
end
def check_stop
return if status != 'Running'
if ARGV[-1] == '-f'
stop(:force => true)
else
stop
end
end
def restart(options = {})
change_state(__method__, options)
end
@ -401,7 +411,7 @@ class Container
# Deletes the switch port. Unlike libvirt, LXD doesn't handle this.
def del_bridge_port(nic)
return true unless /ovswitch/ =~ nic['VN_MAD']
return true unless /ovswitch/ =~ nic['VN_MAD']
cmd = 'sudo ovs-vsctl --if-exists del-port '\
"#{nic['BRIDGE']} #{nic['TARGET']}"

View File

@ -34,10 +34,5 @@ container = Container.get(vm_name, container.config['user.xml'], client)
# ------------------------------------------------------------------------------
# Stop the container, start it
# ------------------------------------------------------------------------------
if ARGV[-1] == '-f'
container.stop(:force => true)
else
container.stop
end
container.check_stop
container.start

View File

@ -37,11 +37,7 @@ container = Container.get(vm_name, xml, client)
# Stop the container & unmap devices if not a wild container
# ------------------------------------------------------------------------------
begin
if ARGV[-1] == '-f'
container.stop(:force => true)
else
container.stop
end
container.check_stop
rescue => exception
OpenNebula.log_error exception
end

View File

@ -116,9 +116,9 @@ module VNMMAD
config, e, s = Open3.capture3(cmd)
if s.exitstatus != 0 && e.include?('cannot create'\
if s.exitstatus != 0 && e.include?('cannot create '\
'user data directory')
cmd.prepend('sudo')
cmd.prepend('sudo ')
config, _e, _s = Open3.capture3(cmd)
end