mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-22 22:03:39 +03:00
B #4827: Add HOTPLUG_NIC_POWEROFF state
This commit is contained in:
parent
73a4e20d92
commit
c1c819fc46
@ -136,7 +136,8 @@ public:
|
||||
PROLOG_MIGRATE_UNKNOWN_FAILURE = 61,
|
||||
DISK_RESIZE = 62,
|
||||
DISK_RESIZE_POWEROFF = 63,
|
||||
DISK_RESIZE_UNDEPLOYED = 64
|
||||
DISK_RESIZE_UNDEPLOYED = 64,
|
||||
HOTPLUG_NIC_POWEROFF = 65
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -204,6 +204,7 @@ module OneGate
|
||||
DISK_RESIZE
|
||||
DISK_RESIZE_POWEROFF
|
||||
DISK_RESIZE_UNDEPLOYED
|
||||
HOTPLUG_NIC_POWEROFF
|
||||
}
|
||||
|
||||
SHORT_VM_STATES={
|
||||
@ -284,7 +285,8 @@ module OneGate
|
||||
"PROLOG_MIGRATE_UNKNOWN_FAILURE" => "fail",
|
||||
"DISK_RESIZE" => "drsz",
|
||||
"DISK_RESIZE_POWEROFF" => "drsz",
|
||||
"DISK_RESIZE_UNDEPLOYED" => "drsz"
|
||||
"DISK_RESIZE_UNDEPLOYED" => "drsz",
|
||||
"HOTPLUG_NIC_POWEROFF" => "hotp"
|
||||
}
|
||||
|
||||
def self.state_to_str(id, lcm_id)
|
||||
|
@ -1723,11 +1723,17 @@ int DispatchManager::attach_nic(int vid, VirtualMachineTemplate* tmpl,
|
||||
cold_attach = vmm->is_cold_nic_attach(vm->get_vmm_mad());
|
||||
}
|
||||
|
||||
if (is_running || (cold_attach && is_poweroff))
|
||||
if (is_running)
|
||||
{
|
||||
vm->set_state(VirtualMachine::ACTIVE);
|
||||
vm->set_state(VirtualMachine::HOTPLUG_NIC);
|
||||
}
|
||||
else if (cold_attach && is_poweroff)
|
||||
{
|
||||
vm->set_state(VirtualMachine::ACTIVE);
|
||||
vm->set_state(VirtualMachine::HOTPLUG_NIC_POWEROFF);
|
||||
}
|
||||
//else POWEROFF && !cold_attach
|
||||
|
||||
vm->set_resched(false);
|
||||
|
||||
@ -1735,17 +1741,15 @@ int DispatchManager::attach_nic(int vid, VirtualMachineTemplate* tmpl,
|
||||
{
|
||||
if (vm->get_lcm_state() == VirtualMachine::HOTPLUG_NIC)
|
||||
{
|
||||
if (!cold_attach)
|
||||
{
|
||||
vm->set_state(VirtualMachine::ACTIVE);
|
||||
vm->set_state(VirtualMachine::RUNNING);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->set_state(VirtualMachine::POWEROFF);
|
||||
vm->set_state(VirtualMachine::LCM_INIT);
|
||||
}
|
||||
vm->set_state(VirtualMachine::ACTIVE);
|
||||
vm->set_state(VirtualMachine::RUNNING);
|
||||
}
|
||||
else if (vm->get_lcm_state() == VirtualMachine::HOTPLUG_NIC_POWEROFF)
|
||||
{
|
||||
vm->set_state(VirtualMachine::POWEROFF);
|
||||
vm->set_state(VirtualMachine::LCM_INIT);
|
||||
}
|
||||
//else POWEROFF / LCM_INIT
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
@ -1769,13 +1773,14 @@ int DispatchManager::attach_nic(int vid, VirtualMachineTemplate* tmpl,
|
||||
|
||||
close_cp_history(vmpool, vm, action, ra);
|
||||
|
||||
if (vm->get_lcm_state() == VirtualMachine::HOTPLUG_NIC)
|
||||
if (vm->get_state() == VirtualMachine::ACTIVE)
|
||||
{
|
||||
vmm->trigger(VMMAction::ATTACH_NIC, vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("DiM", Log::INFO, "VM NIC Successfully attached.");
|
||||
|
||||
vm->clear_attach_nic();
|
||||
vmpool->update_search(vm);
|
||||
}
|
||||
@ -1864,7 +1869,14 @@ int DispatchManager::detach_nic(int vid, int nic_id, const RequestAttributes& ra
|
||||
{
|
||||
vm->set_state(VirtualMachine::ACTIVE);
|
||||
|
||||
vm->set_state(VirtualMachine::HOTPLUG_NIC);
|
||||
if ( is_running )
|
||||
{
|
||||
vm->set_state(VirtualMachine::HOTPLUG_NIC);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->set_state(VirtualMachine::HOTPLUG_NIC_POWEROFF);
|
||||
}
|
||||
|
||||
vm->set_resched(false);
|
||||
|
||||
|
@ -222,6 +222,7 @@ void DispatchManager::poweroff_success_action(int vid)
|
||||
vm->get_lcm_state() == VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF ||
|
||||
vm->get_lcm_state() == VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF ||
|
||||
vm->get_lcm_state() == VirtualMachine::DISK_RESIZE_POWEROFF ||
|
||||
vm->get_lcm_state() == VirtualMachine::HOTPLUG_NIC_POWEROFF ||
|
||||
vm->get_lcm_state() == VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE))
|
||||
{
|
||||
get_quota_template(vm, quota_tmpl, true);
|
||||
|
@ -618,6 +618,7 @@ func (d *Driver) GetState() (state.State, error) {
|
||||
"HOTPLUG_SAVEAS_SUSPENDED",
|
||||
"HOTPLUG_PROLOG_POWEROFF",
|
||||
"HOTPLUG_EPILOG_POWEROFF",
|
||||
"HOTPLUG_NIC_POWEROFF",
|
||||
"PROLOG_MIGRATE_POWEROFF",
|
||||
"PROLOG_MIGRATE_SUSPEND",
|
||||
"DISK_SNAPSHOT_POWEROFF",
|
||||
|
@ -1051,6 +1051,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
|
||||
break;
|
||||
|
||||
case VirtualMachine::HOTPLUG_NIC:
|
||||
case VirtualMachine::HOTPLUG_NIC_POWEROFF:
|
||||
vm->clear_attach_nic();
|
||||
|
||||
vm->set_running_etime(the_time);
|
||||
@ -1379,6 +1380,7 @@ void LifeCycleManager::recover(VirtualMachine * vm, bool success,
|
||||
break;
|
||||
|
||||
case VirtualMachine::HOTPLUG_NIC:
|
||||
case VirtualMachine::HOTPLUG_NIC_POWEROFF:
|
||||
if (success)
|
||||
{
|
||||
lcm_action = LCMAction::ATTACH_NIC_SUCCESS;
|
||||
@ -1662,6 +1664,7 @@ void LifeCycleManager::retry(VirtualMachine * vm)
|
||||
case VirtualMachine::CLEANUP_DELETE:
|
||||
case VirtualMachine::HOTPLUG:
|
||||
case VirtualMachine::HOTPLUG_NIC:
|
||||
case VirtualMachine::HOTPLUG_NIC_POWEROFF:
|
||||
case VirtualMachine::HOTPLUG_SNAPSHOT:
|
||||
case VirtualMachine::HOTPLUG_SAVEAS:
|
||||
case VirtualMachine::HOTPLUG_SAVEAS_POWEROFF:
|
||||
@ -1755,6 +1758,7 @@ void LifeCycleManager::updatesg_action(const LCMAction& la)
|
||||
case VirtualMachine::BOOT_STOPPED_FAILURE:
|
||||
case VirtualMachine::MIGRATE:
|
||||
case VirtualMachine::HOTPLUG_NIC:
|
||||
case VirtualMachine::HOTPLUG_NIC_POWEROFF:
|
||||
case VirtualMachine::UNKNOWN:
|
||||
is_error = true;
|
||||
break;
|
||||
|
@ -1560,6 +1560,15 @@ void LifeCycleManager::attach_nic_success_action(int vid)
|
||||
vmpool->update(vm);
|
||||
vmpool->update_search(vm);
|
||||
}
|
||||
else if ( vm->get_lcm_state() == VirtualMachine::HOTPLUG_NIC_POWEROFF )
|
||||
{
|
||||
vm->clear_attach_nic();
|
||||
|
||||
vmpool->update(vm);
|
||||
vmpool->update_search(vm);
|
||||
|
||||
dm->trigger(DMAction::POWEROFF_SUCCESS,vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("LCM",Log::ERROR,"attach_nic_success_action, VM in a wrong state");
|
||||
@ -1601,6 +1610,14 @@ void LifeCycleManager::attach_nic_failure_action(int vid)
|
||||
|
||||
vm->unlock();
|
||||
}
|
||||
else if ( vm->get_lcm_state() == VirtualMachine::HOTPLUG_NIC_POWEROFF )
|
||||
{
|
||||
vm->unlock();
|
||||
|
||||
vmpool->delete_attach_nic(vid);
|
||||
|
||||
dm->trigger(DMAction::POWEROFF_SUCCESS, vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("LCM",Log::ERROR,"attach_nic_failure_action, VM in a wrong state");
|
||||
@ -1639,14 +1656,31 @@ void LifeCycleManager::detach_nic_success_action(int vid)
|
||||
|
||||
vmpool->update(vm);
|
||||
vmpool->update_search(vm);
|
||||
|
||||
}
|
||||
else if ( vm->get_lcm_state() == VirtualMachine::HOTPLUG_NIC_POWEROFF )
|
||||
{
|
||||
vm->unlock();
|
||||
|
||||
vmpool->delete_attach_nic(vid);
|
||||
|
||||
vm = vmpool->get(vid);
|
||||
|
||||
if ( vm == nullptr )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vmpool->update(vm);
|
||||
vmpool->update_search(vm);
|
||||
|
||||
dm->trigger(DMAction::POWEROFF_SUCCESS, vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("LCM",Log::ERROR,"detach_nic_success_action, VM in a wrong state");
|
||||
vm->unlock();
|
||||
}
|
||||
|
||||
vm->unlock();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -1671,6 +1705,14 @@ void LifeCycleManager::detach_nic_failure_action(int vid)
|
||||
|
||||
vmpool->update(vm);
|
||||
}
|
||||
else if ( vm->get_lcm_state() == VirtualMachine::HOTPLUG_NIC_POWEROFF )
|
||||
{
|
||||
vm->clear_attach_nic();
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
dm->trigger(DMAction::POWEROFF_SUCCESS, vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("LCM",Log::ERROR,"detach_nic_failure_action, VM in a wrong state");
|
||||
|
@ -293,6 +293,9 @@ const (
|
||||
|
||||
// DiskResizeUndeployed lcm state
|
||||
DiskResizeUndeployed LCMState = 64
|
||||
|
||||
// HotplugNicPoweroff lcm state
|
||||
HotplugNicPoweroff = 65
|
||||
)
|
||||
|
||||
func (s LCMState) isValid() bool {
|
||||
@ -430,6 +433,8 @@ func (s LCMState) String() string {
|
||||
return "DISK_RESIZE_POWEROFF"
|
||||
case DiskResizeUndeployed:
|
||||
return "DISK_RESIZE_UNDEPLOYED"
|
||||
case HotplugNicPoweroff:
|
||||
return "HOTPLUG_NIC_POWEROFF"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
@ -153,7 +153,8 @@ public class VirtualMachine extends PoolElement{
|
||||
"PROLOG_MIGRATE_UNKNOWN_FAILURE",
|
||||
"DISK_RESIZE",
|
||||
"DISK_RESIZE_POWEROFF",
|
||||
"DISK_RESIZE_UNDEPLOYED"
|
||||
"DISK_RESIZE_UNDEPLOYED",
|
||||
"HOTPLUG_NIC_POWEROFF"
|
||||
};
|
||||
|
||||
private static final String[] SHORT_LCM_STATES =
|
||||
@ -222,7 +223,8 @@ public class VirtualMachine extends PoolElement{
|
||||
"fail", // PROLOG_MIGRATE_UNKNOWN_FAILURE
|
||||
"drsz", // DISK_RESIZE
|
||||
"drsz", // DISK_RESIZE_POWEROFF
|
||||
"drsz" // DISK_RESIZE_UNDEPLOYED
|
||||
"drsz", // DISK_RESIZE_UNDEPLOYED
|
||||
"hotp" // HOTPLUG_NIC_POWEROFF
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -153,7 +153,8 @@ LCM_STATE = IntEnum('LCM_STATE', '''
|
||||
PROLOG_MIGRATE_UNKNOWN_FAILURE
|
||||
DISK_RESIZE
|
||||
DISK_RESIZE_POWEROFF
|
||||
DISK_RESIZE_UNDEPLOYED''', start=0)
|
||||
DISK_RESIZE_UNDEPLOYED
|
||||
HOTPLUG_NIC_POWEROFF''', start=0)
|
||||
|
||||
MARKETPLACEAPP_STATES = IntEnum('MARKETPLACEAPP_STATES', '''INIT READY LOCKED
|
||||
ERROR DISABLED''', start=0)
|
||||
|
@ -122,6 +122,7 @@ module OpenNebula
|
||||
DISK_RESIZE
|
||||
DISK_RESIZE_POWEROFF
|
||||
DISK_RESIZE_UNDEPLOYED
|
||||
HOTPLUG_NIC_POWEROFF
|
||||
}
|
||||
|
||||
SHORT_VM_STATES={
|
||||
@ -202,7 +203,8 @@ module OpenNebula
|
||||
"PROLOG_MIGRATE_UNKNOWN_FAILURE" => "fail",
|
||||
"DISK_RESIZE" => "drsz",
|
||||
"DISK_RESIZE_POWEROFF" => "drsz",
|
||||
"DISK_RESIZE_UNDEPLOYED" => "drsz"
|
||||
"DISK_RESIZE_UNDEPLOYED" => "drsz",
|
||||
"HOTPLUG_NIC_POWEROFF" => "hotp"
|
||||
}
|
||||
|
||||
HISTORY_ACTION=%w{none migrate live-migrate shutdown shutdown-hard
|
||||
|
@ -97,6 +97,7 @@ VNC_STATES = [
|
||||
"62" #DISK_RESIZE
|
||||
#63, #DISK_RESIZE_POWEROFF
|
||||
#64 #DISK_RESIZE_UNDEPLOYED
|
||||
#65 #HOTPLUG_NIC_POWEROFF
|
||||
]
|
||||
|
||||
class OpenNebulaVNC
|
||||
|
@ -120,7 +120,8 @@ define(function(require) {
|
||||
"PROLOG_MIGRATE_UNKNOWN_FAILURE",
|
||||
"DISK_RESIZE",
|
||||
"DISK_RESIZE_POWEROFF",
|
||||
"DISK_RESIZE_UNDEPLOYED"
|
||||
"DISK_RESIZE_UNDEPLOYED",
|
||||
"HOTPLUG_NIC_POWEROFF"
|
||||
];
|
||||
|
||||
var LCM_STATES = {
|
||||
@ -188,7 +189,8 @@ define(function(require) {
|
||||
PROLOG_MIGRATE_UNKNOWN_FAILURE : 61,
|
||||
DISK_RESIZE : 62,
|
||||
DISK_RESIZE_POWEROFF : 63,
|
||||
DISK_RESIZE_UNDEPLOYED : 64
|
||||
DISK_RESIZE_UNDEPLOYED : 64,
|
||||
HOTPLUG_NIC_POWEROFF : 65
|
||||
};
|
||||
|
||||
var SHORT_LCM_STATES_STR = [
|
||||
@ -256,7 +258,8 @@ define(function(require) {
|
||||
Locale.tr("FAILURE"), // PROLOG_MIGRATE_UNKNOWN_FAILURE
|
||||
Locale.tr("DISK_RSZ"), // DISK_RESIZE
|
||||
Locale.tr("DISK_RSZ"), // DISK_RESIZE_POWEROFF
|
||||
Locale.tr("DISK_RSZ") // DISK_RESIZE_UNDEPLOYED
|
||||
Locale.tr("DISK_RSZ"), // DISK_RESIZE_UNDEPLOYED
|
||||
Locale.tr("HOTPLUG") // HOTPLUG_NIC_POWEROFF
|
||||
];
|
||||
|
||||
var VNC_STATES = [
|
||||
|
@ -880,6 +880,7 @@ define(function(require) {
|
||||
break;
|
||||
case OpenNebulaVM.LCM_STATES.HOTPLUG:
|
||||
case OpenNebulaVM.LCM_STATES.HOTPLUG_NIC:
|
||||
case OpenNebulaVM.LCM_STATES.HOTPLUG_NIC_POWEROFF:
|
||||
case OpenNebulaVM.LCM_STATES.HOTPLUG_SAVEAS:
|
||||
case OpenNebulaVM.LCM_STATES.HOTPLUG_SAVEAS_POWEROFF:
|
||||
case OpenNebulaVM.LCM_STATES.HOTPLUG_SAVEAS_SUSPENDED:
|
||||
|
@ -300,8 +300,10 @@ define(function(require) {
|
||||
// Attach / Detach
|
||||
if (!is_pci){
|
||||
if (
|
||||
that.element.STATE == OpenNebulaVM.STATES.ACTIVE &&
|
||||
that.element.LCM_STATE == OpenNebulaVM.LCM_STATES.HOTPLUG_NIC
|
||||
that.element.STATE == OpenNebulaVM.STATES.ACTIVE && (
|
||||
that.element.LCM_STATE == OpenNebulaVM.LCM_STATES.HOTPLUG_NIC ||
|
||||
that.element.LCM_STATE == OpenNebulaVM.LCM_STATES.HOTPLUG_NIC_POWEROFF
|
||||
)
|
||||
) {
|
||||
actions = Locale.tr("attach/detach in progress");
|
||||
} else {
|
||||
|
@ -84,6 +84,7 @@ define(function(require) {
|
||||
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.CLEANUP_DELETE ] = ["VM.updateconf"];
|
||||
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_SNAPSHOT ] = [];
|
||||
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_NIC ] = [];
|
||||
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_NIC_POWEROFF ] = [];
|
||||
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_SAVEAS ] = [];
|
||||
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_SAVEAS_POWEROFF ] = ["VM.updateconf"];
|
||||
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_SAVEAS_SUSPENDED ] = [];
|
||||
|
@ -287,6 +287,8 @@ int VirtualMachine::lcm_state_from_str(string& st, LcmState& state)
|
||||
state = DISK_RESIZE_POWEROFF;
|
||||
} else if ( st == "DISK_RESIZE_UNDEPLOYED" ) {
|
||||
state = DISK_RESIZE_UNDEPLOYED;
|
||||
} else if ( st == "HOTPLUG_NIC_POWEROFF" ) {
|
||||
state = HOTPLUG_NIC_POWEROFF;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
@ -424,6 +426,8 @@ string& VirtualMachine::lcm_state_to_str(string& st, LcmState state)
|
||||
st = "DISK_RESIZE_POWEROFF"; break;
|
||||
case DISK_RESIZE_UNDEPLOYED:
|
||||
st = "DISK_RESIZE_UNDEPLOYED"; break;
|
||||
case HOTPLUG_NIC_POWEROFF:
|
||||
st = "HOTPLUG_NIC_POWEROFF"; break;
|
||||
}
|
||||
|
||||
return st;
|
||||
|
Loading…
x
Reference in New Issue
Block a user