Skip to content

Commit

Permalink
F #911: call reconfigure when detaching a nic/alias.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Huertas committed Jan 10, 2019
1 parent 9398259 commit dc1a2c2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
2 changes: 2 additions & 0 deletions share/etc/oned.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@ VM_RESTRICTED_ATTR = "NIC/OPENNEBULA_MANAGED"
VM_RESTRICTED_ATTR = "NIC/VCENTER_INSTANCE_ID"
VM_RESTRICTED_ATTR = "NIC/VCENTER_NET_REF"
VM_RESTRICTED_ATTR = "NIC/VCENTER_PORTGROUP_TYPE"
VM_RESTRICTED_ATTR = "NIC_ALIAS/EXTERNAL"
VM_RESTRICTED_ATTR = "NIC_DEFAULT/MAC"
VM_RESTRICTED_ATTR = "NIC_DEFAULT/VLAN_ID"
VM_RESTRICTED_ATTR = "NIC_DEFAULT/BRIDGE"
Expand Down Expand Up @@ -1209,6 +1210,7 @@ INHERIT_VNET_ATTR = "CONF"
INHERIT_VNET_ATTR = "BRIDGE_CONF"
INHERIT_VNET_ATTR = "OVS_BRIDGE_CONF"
INHERIT_VNET_ATTR = "IP_LINK_CONF"
INHERIT_VNET_ATTR = "EXTERNAL"

INHERIT_VNET_ATTR = "VCENTER_NET_REF"
INHERIT_VNET_ATTR = "VCENTER_SWITCH_NAME"
Expand Down
17 changes: 15 additions & 2 deletions src/vmm/VirtualMachineManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2408,6 +2408,9 @@ void VirtualMachineManager::detach_nic_action(
string vm_tmpl;
string * drv_msg;
string error_str;
string prolog_cmd;
string disk_path;
string password;

// Get the VM from the pool
vm = vmpool->get(vid);
Expand All @@ -2430,6 +2433,11 @@ void VirtualMachineManager::detach_nic_action(
goto error_driver;
}

if ( do_context_command(vm, password, prolog_cmd, disk_path) == -1 )
{
goto error_no_tm_command;
}

// Invoke driver method
drv_msg = format_message(
vm->get_hostname(),
Expand All @@ -2438,9 +2446,9 @@ void VirtualMachineManager::detach_nic_action(
"",
"",
"",
prolog_cmd,
"",
"",
"",
disk_path,
vm->to_xml(vm_tmpl),
vm->get_ds_id(),
-1);
Expand All @@ -2463,6 +2471,11 @@ void VirtualMachineManager::detach_nic_action(
os << "detach_nic_action, error getting driver " << vm->get_vmm_mad();
goto error_common;

error_no_tm_command:
os.str("");
os << "Cannot set context disk to update it for VM " << vm->get_oid();
goto error_common;

error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
Expand Down
35 changes: 30 additions & 5 deletions src/vmm_mad/exec/one_vmm_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,15 @@ def detach_nic(id, drv_message)
action = ACTION[:detach_nic]
xml_data = decode(drv_message)

tm_command = xml_data.elements['TM_COMMAND']
tm_command = tm_command.text if tm_command

target_path = xml_data.elements['DISK_TARGET_PATH']
target_path = target_path.text if target_path

target_device = xml_data.elements['VM/TEMPLATE/CONTEXT/TARGET']
target_device = target_device.text if target_device

nic_alias = false
external = false

Expand All @@ -1036,6 +1045,8 @@ def detach_nic(id, drv_message)
return
end

action = VmmAction.new(self, id, :detach_nic, drv_message)

if !nic_alias
steps=[
# Detach the NIC
Expand All @@ -1062,13 +1073,27 @@ def detach_nic(id, drv_message)
steps = []
end

if steps.empty?
send_message(action, RESULT[:success], id, "")
else
action = VmmAction.new(self, id, :detach_nic, drv_message)
steps << {
:driver => :vmm,
:action => :prereconfigure,
:parameters => [:deploy_id, target_device]
}

action.run(steps)
if tm_command && !tm_command.empty?
steps << {
:driver => :tm,
:action => :tm_context,
:parameters => tm_command.strip.split(' ')
}
end

steps << {
:driver => :vmm,
:action => :reconfigure,
:parameters => [:deploy_id, target_device, target_path]
}

action.run(steps)
end

#
Expand Down

0 comments on commit dc1a2c2

Please sign in to comment.