1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-01 05:47:01 +03:00
one/include/LifeCycleManager.h
Ruben S. Montero 865908de1c
F #5989: Live update of Virtual Network attributes
co-authored-by: Pavel Czerný <pczerny@opennebula.systems>
co-authored-by: Frederick Borges <fborges@opennebula.io>
co-authored-by: Christian González <cgonzalez@opennebula.io>

* VNET updates trigger a driver action on running VMs with NICs in the
  network.

* VNET includes a sets with VM status: updated, outdated, error and
  updating. With VMs in each state.

* VNET flags error situations with a new state UPDATE_FAILURE.

* The same procedure is applied when an AR is updated (only VMs in that
  AR are updated).

* A new options in the one.vn.recover API call enable to recover or
  retry this VM update operations.

* The following attributes can be live-updated per VNET driver:
    - PHYDEV (novlan, vlan, ovs driver)
    - MTU (vlan, ovs driver)
    - VLAN_ID (vlan, ovs driver)
    - QINQ_TYPE (ovs driver)
    - CVLANS (ovs driver)
    - VLAN_TAGGED_ID (ovs driver)
    - OUTER_VLAN_ID (ovs driver)
    - INBOUND_AVG_BW (SG, ovs driver + KVM)
    - INBOUND_PEAK_BW (SG, ovs driver + KVM)
    - INBOUND_PEAK_KB (SG, ovs driver + KVM)
    - OUTBOUND_AVG_BW (SG, ovs driver + KVM)
    - OUTBOUND_PEAK_BW (SG, ovs driver + KVM)
    - OUTBOUND_PEAK_KB (SG, ovs driver + KVM)

* New API call one.vm.updatenic, allows to update individual NICs
  without the need of detach/attach (only QoS supported).

* Update operations for: 802.1Q, bridge, fw, ovswitch, ovswitch_vxlan
  and vxlan network drivers.

* VNET attributes (old values) stored in VNET_UPDATE to allow
  implementation of update operations. The attribute is removed after a
  successful update.

* Updates to CLI onevnet (--retry option) / onevm (nicupdate command)

* XSD files updated to reflect the new data model

* Ruby and JAVA bindings updated: new VNET state and recover option, new
  VM API call.

* Suntone and Fireedge implementation (lease status, recover option, new
  states)

TODO: Virtual Functions does not support this functionality

iii
2022-11-16 15:06:49 +01:00

265 lines
8.8 KiB
C++

/* -------------------------------------------------------------------------- */
/* Copyright 2002-2022, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
#ifndef LIFE_CYCLE_MANAGER_H_
#define LIFE_CYCLE_MANAGER_H_
#include "Listener.h"
#include "VMActions.h"
//Forward definitions
class TransferManager;
class DispatchManager;
class VirtualMachineManager;
class ImageManager;
class ClusterPool;
class HostPool;
class ImagePool;
class DatastorePool;
class SecurityGroupPool;
class VirtualMachinePool;
class VirtualMachine;
class VirtualNetworkPool;
struct RequestAttributes;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/**
* The Virtual Machine Life-cycle Manager module. This class is responsible for
* managing the life-cycle of a Virtual Machine.
*/
class LifeCycleManager : public Listener
{
public:
LifeCycleManager()
: Listener("Life Cycle Manager")
{
};
~LifeCycleManager() = default;
/**
* This functions starts a new thread for the Life-cycle Manager. This
* thread will wait in an action loop till it receives ACTION_FINALIZE.
* @return 0 on success.
*/
int start();
/**
* Initializes internal pointers to other managers. Must be called when
* all the other managers exist in Nebula::instance
*/
void init_managers();
/**
* Recovers a VM by self-triggering the associated lost transition.
* @param vm to be recovered
* @param success trigger successful transition if true, fail otherwise
*/
void recover(VirtualMachine * vm, bool success, const RequestAttributes& ra);
/**
* Retries the last VM operation that lead to a failure. The underlying
* driver actions may be invoked and should be "re-entrant".
*/
void retry(VirtualMachine * vm);
// -------------------------------------------------------------------------
// Internal Actions, triggered by OpenNebula components & drivers
// -------------------------------------------------------------------------
void start_prolog_migrate(VirtualMachine* vm);
void revert_migrate_after_failure(VirtualMachine* vm);
void trigger_save_success(int vid);
void trigger_save_failure(int vid);
void trigger_deploy_success(int vid);
void trigger_deploy_failure(int vid);
void trigger_shutdown_success(int vid);
void trigger_shutdown_failure(int vid);
void trigger_monitor_suspend(int vid);
void trigger_monitor_done(int vid);
void trigger_monitor_poweroff(int vid);
void trigger_monitor_poweron(int vid);
void trigger_prolog_success(int vid);
void trigger_prolog_failure(int vid);
void trigger_epilog_success(int vid);
void trigger_epilog_failure(int vid);
void trigger_attach_success(int vid);
void trigger_attach_failure(int vid);
void trigger_detach_success(int vid);
void trigger_detach_failure(int vid);
void trigger_saveas_success(int vid);
void trigger_saveas_failure(int vid);
void trigger_attach_nic_success(int vid);
void trigger_attach_nic_failure(int vid);
void trigger_detach_nic_success(int vid);
void trigger_detach_nic_failure(int vid);
void trigger_cleanup_callback(int vid);
void trigger_snapshot_create_success(int vid);
void trigger_snapshot_create_failure(int vid);
void trigger_snapshot_revert_success(int vid);
void trigger_snapshot_revert_failure(int vid);
void trigger_snapshot_delete_success(int vid);
void trigger_snapshot_delete_failure(int vid);
void trigger_disk_snapshot_success(int vid);
void trigger_disk_snapshot_failure(int vid);
void trigger_disk_lock_success(int vid);
void trigger_disk_lock_failure(int vid);
void trigger_disk_resize_success(int vid);
void trigger_disk_resize_failure(int vid);
void trigger_update_conf_success(int vid);
void trigger_update_conf_failure(int vid);
void trigger_resize_success(int vid);
void trigger_resize_failure(int vid);
void trigger_backup_success(int vid);
void trigger_backup_failure(int vid);
// -------------------------------------------------------------------------
// External Actions, triggered by user requests
// -------------------------------------------------------------------------
void trigger_deploy(int vid);
void trigger_suspend(int vid, const RequestAttributes& ra);
void trigger_restore(int vid, const RequestAttributes& ra);
void trigger_stop(int vid, const RequestAttributes& ra);
void trigger_checkpoint(int vid);
void trigger_migrate(int vid, const RequestAttributes& ra,
VMActions::Action vm_action);
void trigger_migrate(int vid, const RequestAttributes& ra)
{
trigger_migrate(vid, ra, VMActions::MIGRATE_ACTION);
}
void trigger_migrate_poweroff(int vid, const RequestAttributes& ra)
{
trigger_migrate(vid, ra, VMActions::POFF_MIGRATE_ACTION);
}
void trigger_migrate_poweroff_hard(int vid, const RequestAttributes& ra)
{
trigger_migrate(vid, ra, VMActions::POFF_HARD_MIGRATE_ACTION);
}
void trigger_live_migrate(int vid, const RequestAttributes& ra);
void trigger_shutdown(int vid, bool hard, const RequestAttributes& ra);
void trigger_undeploy(int vid, bool hard, const RequestAttributes& ra);
void trigger_undeploy(int vid, const RequestAttributes& ra)
{
trigger_undeploy(vid, false, ra);
}
void trigger_undeploy_hard(int vid, const RequestAttributes& ra)
{
trigger_undeploy(vid, true, ra);
}
void trigger_poweroff(int vid, const RequestAttributes& ra);
void trigger_poweroff_hard(int vid, const RequestAttributes& ra);
void trigger_poweroff(int vid, bool hard, const RequestAttributes& ra);
void trigger_updatesg(int sgid);
void trigger_restart(int vid, const RequestAttributes& ra);
void trigger_delete(int vid, const RequestAttributes& ra);
void trigger_delete_recreate(int vid, const RequestAttributes& ra);
void trigger_updatevnet(int vnid);
private:
/**
* Pointer to the Virtual Machine Pool, to access VMs
*/
VirtualMachinePool * vmpool = nullptr;
/**
* Pointer to the Host Pool, to access hosts
*/
HostPool * hpool = nullptr;
/**
* Pointer to the Image Pool, to access images
*/
ImagePool * ipool = nullptr;
/**
* Pointer to the Datastore Pool, to access images
*/
DatastorePool * dspool = nullptr;
/**
* Pointer to the SecurityGroup Pool
*/
SecurityGroupPool * sgpool = nullptr;
/**
* Pointer to the Cluster Pool
*/
ClusterPool * clpool = nullptr;
/**
* Pointer to the Cluster Pool
*/
VirtualNetworkPool * vnpool = nullptr;
/**
* Pointer to TransferManager
*/
TransferManager * tm = nullptr;
/**
* Pointer to VirtualMachineManager
*/
VirtualMachineManager * vmm = nullptr;
/**
* Pointer to DispatchManager
*/
DispatchManager * dm = nullptr;
/**
* Pointer to ImageManager
*/
ImageManager * imagem = nullptr;
/**
* Cleans up a VM, canceling any pending or ongoing action and closing
* the history registers
*
* @param vm with the lock acquired
* @param dispose true if the vm will end in DONE, false to resubmit to PENDING
* @param image_id If the VM is in the middle of a save as operation, an
* image may need to be set to error state.
*/
void clean_up_vm(VirtualMachine *vm, bool dispose, int& image_id,
int uid, int gid, int req_id, Template& quota_tmpl);
};
#endif /*LIFE_CYCLE_MANAGER_H_*/