mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
(cherry picked from commit 31a1cb9db7953dffec96255ad9b3dbc8d17a9ae3)
This commit is contained in:
parent
d2a33ecbb5
commit
082fbe477e
@ -175,6 +175,11 @@ class Container
|
||||
|
||||
def stop(options = { :timeout => 120 })
|
||||
change_state(__method__, options)
|
||||
|
||||
# Remove nic from ovs-switch if needed
|
||||
@one.get_nics.each do |nic|
|
||||
del_bridge_port(nic) # network driver matching implemented here
|
||||
end
|
||||
end
|
||||
|
||||
def restart(options = {})
|
||||
@ -211,7 +216,8 @@ class Container
|
||||
device.include?('eth') && config['hwaddr'] == mac
|
||||
end
|
||||
|
||||
update
|
||||
# Removes nic from ovs-switch if needed
|
||||
update if del_bridge_port(@one.get_nic_by_mac(mac))
|
||||
end
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
@ -382,6 +388,21 @@ class Container
|
||||
|
||||
private
|
||||
|
||||
# Deletes the switch port. Unlike libvirt, LXD doesn't handle this.
|
||||
def del_bridge_port(nic)
|
||||
return true unless /ovswitch/ =~ nic['VN_MAD']
|
||||
|
||||
cmd = 'sudo ovs-vsctl --if-exists del-port '\
|
||||
"#{nic['BRIDGE']} #{nic['TARGET']}"
|
||||
|
||||
rc, _o, e = Command.execute(cmd, false)
|
||||
|
||||
return true if rc.zero?
|
||||
|
||||
OpenNebula.log_error "#{__method__}: #{e}"
|
||||
false
|
||||
end
|
||||
|
||||
# Waits or no for response depending on wait value
|
||||
def wait?(response, wait, timeout)
|
||||
@client.wait(response, timeout) unless wait == false
|
||||
|
@ -23,12 +23,13 @@ require 'container'
|
||||
require_relative '../../scripts_common'
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Action Arguments, STDIN includes XML description of the OpenNebula VM
|
||||
# Action Arguments, STDIN doesn't include XML description of the OpenNebula VM
|
||||
# ------------------------------------------------------------------------------
|
||||
vm_name = ARGV[0]
|
||||
|
||||
client = LXDClient.new
|
||||
container = Container.get(vm_name, nil, client)
|
||||
container = Container.get(vm_name, container.config['user.xml'], client)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Stop the container, start it
|
||||
|
Loading…
x
Reference in New Issue
Block a user