2008-06-17 20:27:32 +04:00
/* -------------------------------------------------------------------------- */
2022-04-07 20:49:58 +03:00
/* Copyright 2002-2022, OpenNebula Project, OpenNebula Systems */
2008-06-17 20:27:32 +04:00
/* */
/* 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_
2020-07-24 17:00:59 +03:00
# include "Listener.h"
# include "VMActions.h"
2008-06-17 20:27:32 +04:00
2015-04-24 17:27:08 +03:00
//Forward definitions
class TransferManager ;
class DispatchManager ;
class VirtualMachineManager ;
2015-07-17 19:31:38 +03:00
class ImageManager ;
2020-07-02 23:42:10 +03:00
class ClusterPool ;
class HostPool ;
class ImagePool ;
class SecurityGroupPool ;
class VirtualMachinePool ;
class VirtualMachine ;
2017-02-07 19:26:23 +03:00
struct RequestAttributes ;
2015-04-24 17:27:08 +03:00
2017-02-03 16:19:15 +03:00
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/**
* The Virtual Machine Life - cycle Manager module . This class is responsible for
* managing the life - cycle of a Virtual Machine .
*/
2020-07-24 17:00:59 +03:00
class LifeCycleManager : public Listener
2017-02-03 16:19:15 +03:00
{
public :
2020-07-24 17:00:59 +03:00
LifeCycleManager ( )
: Listener ( " Life Cycle Manager " )
2017-02-03 16:19:15 +03:00
{
2008-06-17 20:27:32 +04:00
} ;
2019-07-26 14:45:26 +03:00
~ LifeCycleManager ( ) = default ;
2017-02-03 16:19:15 +03:00
2008-06-17 20:27:32 +04:00
/**
2010-12-30 03:11:40 +03:00
* This functions starts a new thread for the Life - cycle Manager . This
2008-06-17 20:27:32 +04:00
* thread will wait in an action loop till it receives ACTION_FINALIZE .
* @ return 0 on success .
*/
int start ( ) ;
2015-04-24 17:27:08 +03:00
/**
* Initializes internal pointers to other managers . Must be called when
* all the other managers exist in Nebula : : instance
*/
void init_managers ( ) ;
2013-05-17 02:45:38 +04:00
/**
* Recovers a VM by self - triggering the associated lost transition .
* @ param vm to be recovered
* @ param success trigger successful transition if true , fail otherwise
*/
2017-02-07 19:26:23 +03:00
void recover ( VirtualMachine * vm , bool success , const RequestAttributes & ra ) ;
2013-05-17 02:45:38 +04:00
2015-07-01 22:15:40 +03:00
/**
* Retries the last VM operation that lead to a failure . The underlying
* driver actions may be invoked and should be " re-entrant " .
*/
2015-04-21 18:15:10 +03:00
void retry ( VirtualMachine * vm ) ;
2020-07-24 17:00:59 +03:00
// -------------------------------------------------------------------------
// 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 ) ;
2008-06-17 20:27:32 +04:00
2020-11-17 13:24:52 +03:00
void trigger_resize_success ( int vid ) ;
void trigger_resize_failure ( int vid ) ;
2020-07-24 17:00:59 +03:00
// -------------------------------------------------------------------------
// 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 vid ) ;
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 ) ;
private :
2008-06-17 20:27:32 +04:00
/**
* Pointer to the Virtual Machine Pool , to access VMs
*/
2020-07-24 17:00:59 +03:00
VirtualMachinePool * vmpool = nullptr ;
2010-12-30 03:11:40 +03:00
2008-06-22 05:51:49 +04:00
/**
* Pointer to the Host Pool , to access hosts
*/
2020-07-24 17:00:59 +03:00
HostPool * hpool = nullptr ;
2008-06-17 20:27:32 +04:00
2015-04-24 17:27:08 +03:00
/**
* Pointer to the Image Pool , to access images
*/
2020-07-24 17:00:59 +03:00
ImagePool * ipool = nullptr ;
2015-04-24 17:27:08 +03:00
2016-03-02 01:31:31 +03:00
/**
* Pointer to the SecurityGroup Pool
*/
2020-07-24 17:00:59 +03:00
SecurityGroupPool * sgpool = nullptr ;
2016-03-02 01:31:31 +03:00
2016-04-05 13:47:21 +03:00
/**
* Pointer to the Cluster Pool
*/
2020-07-24 17:00:59 +03:00
ClusterPool * clpool = nullptr ;
2016-04-05 13:47:21 +03:00
2015-04-24 17:27:08 +03:00
/**
* Pointer to TransferManager
*/
2020-07-24 17:00:59 +03:00
TransferManager * tm = nullptr ;
2015-04-24 17:27:08 +03:00
/**
* Pointer to VirtualMachineManager
*/
2020-07-24 17:00:59 +03:00
VirtualMachineManager * vmm = nullptr ;
2015-04-24 17:27:08 +03:00
/**
* Pointer to DispatchManager
*/
2020-07-24 17:00:59 +03:00
DispatchManager * dm = nullptr ;
2008-06-17 20:27:32 +04:00
2015-07-17 19:31:38 +03:00
/**
* Pointer to ImageManager
*/
2020-07-24 17:00:59 +03:00
ImageManager * imagem = nullptr ;
2008-06-17 20:27:32 +04:00
2010-12-30 03:11:40 +03:00
/**
* Cleans up a VM , canceling any pending or ongoing action and closing
* the history registers
2013-03-14 21:03:15 +04:00
*
* @ 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 .
2010-12-30 03:11:40 +03:00
*/
2019-07-26 14:45:26 +03:00
void clean_up_vm ( VirtualMachine * vm , bool dispose , int & image_id ,
2020-07-24 17:00:59 +03:00
int uid , int gid , int req_id ) ;
2008-06-17 20:27:32 +04:00
} ;
# endif /*LIFE_CYCLE_MANAGER_H_*/