Feature #1691: Process VMM driver attach/detach nic response

This commit is contained in:
Carlos Martín committed 2012-12-13 15:53:07 +01:00
1 parent 7841190b27
commit f451c18920
4 files changed
+66 -2

No files matched your search

+14
View File
@@ -42,6 +42,8 @@ class VirtualMachineDriver < OpenNebulaDriver
:log => "LOG",
:attach_disk => "ATTACHDISK",
:detach_disk => "DETACHDISK",
:attach_nic => "ATTACHNIC",
:detach_nic => "DETACHNIC",
}
POLL_ATTRIBUTE = {
@@ -89,6 +91,8 @@ class VirtualMachineDriver < OpenNebulaDriver
register_action(ACTION[:poll].to_sym, method("poll"))
register_action(ACTION[:attach_disk].to_sym, method("attach_disk"))
register_action(ACTION[:detach_disk].to_sym, method("detach_disk"))
register_action(ACTION[:attach_nic].to_sym, method("attach_nic"))
register_action(ACTION[:detach_nic].to_sym, method("detach_nic"))
end
# Decodes the encoded XML driver message received from the core
@@ -168,6 +172,16 @@ class VirtualMachineDriver < OpenNebulaDriver
send_message(ACTION[:detach_disk],RESULT[:failure],id,error)
end
def attach_nic(id, drv_message)
error = "Action not implemented by driver #{self.class}"
send_message(ACTION[:attach_nic],RESULT[:failure],id,error)
end
def detach_nic(id, drv_message)
error = "Action not implemented by driver #{self.class}"
send_message(ACTION[:detach_nic],RESULT[:failure],id,error)
end
private
# Interface to handle the pending events from the ActionManager Interface
def delete_running_action(action_id)
+2 -2
View File
@@ -1411,7 +1411,7 @@ void VirtualMachine::get_disk_info(int& max_disk_id,
int disk_id;
int num_disks;
max_disk_id = 0;
max_disk_id = -1;
num_disks = obj_template->get("DISK", disks);
@@ -1679,7 +1679,7 @@ void VirtualMachine::get_nic_info(int& max_nic_id)
int nic_id;
int num_nics;
max_nic_id = 0;
max_nic_id = -1;
num_nics = obj_template->get("NIC", nics);
+38
View File
@@ -373,6 +373,44 @@ void VirtualMachineManagerDriver::protocol(
lcm->trigger(LifeCycleManager::DETACH_FAILURE, id);
}
}
else if ( action == "ATTACHNIC" )
{
Nebula &ne = Nebula::instance();
LifeCycleManager *lcm = ne.get_lcm();
if ( result == "SUCCESS" )
{
vm->log("VMM", Log::ERROR, "VM NIC Successfully attached.");
lcm->trigger(LifeCycleManager::ATTACH_NIC_SUCCESS, id);
}
else
{
log_error(vm, os, is, "Error attaching new VM NIC");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::ATTACH_NIC_FAILURE, id);
}
}
else if ( action == "DETACHNIC" )
{
Nebula &ne = Nebula::instance();
LifeCycleManager *lcm = ne.get_lcm();
if ( result == "SUCCESS" )
{
vm->log("VMM",Log::ERROR,"VM NIC Successfully detached.");
lcm->trigger(LifeCycleManager::DETACH_NIC_SUCCESS, id);
}
else
{
log_error(vm,os,is,"Error detaching VM NIC");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::DETACH_NIC_FAILURE, id);
}
}
else if ( action == "POLL" )
{
if (result == "SUCCESS")
+12
View File
@@ -128,6 +128,18 @@ class DummyDriver < VirtualMachineDriver
send_message(ACTION[:detach_disk],result,id)
end
def attach_nic(id, drv_message)
result = retrieve_result("attach_nic")
send_message(ACTION[:attach_nic],result,id)
end
def detach_nic(id, drv_message)
result = retrieve_result("detach_nic")
send_message(ACTION[:detach_nic],result,id)
end
def poll(id, drv_message)
result = retrieve_result("poll")