2011-06-02 02:55:43 +04:00
/* -------------------------------------------------------------------------- */
2024-07-29 15:25:20 +03:00
/* Copyright 2002-2024, OpenNebula Project, OpenNebula Systems */
2011-06-02 02:55:43 +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 REQUEST_MANAGER_UPDATE_TEMPLATE_H
# define REQUEST_MANAGER_UPDATE_TEMPLATE_H
# include "Request.h"
# include "Nebula.h"
2023-07-03 19:15:52 +03:00
# include "BackupJobPool.h"
2019-12-10 13:45:15 +03:00
# include "ClusterPool.h"
# include "DatastorePool.h"
# include "DocumentPool.h"
# include "HookPool.h"
# include "HostPool.h"
# include "ImagePool.h"
# include "MarketPlacePool.h"
# include "MarketPlaceAppPool.h"
# include "SecurityGroupPool.h"
# include "VdcPool.h"
# include "VirtualMachinePool.h"
# include "VirtualNetworkPool.h"
# include "VirtualRouterPool.h"
# include "VMGroupPool.h"
# include "VMTemplatePool.h"
# include "VNTemplatePool.h"
# include "ZonePool.h"
2011-06-02 02:55:43 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class RequestManagerUpdateTemplate : public Request
{
protected :
2020-07-02 23:42:10 +03:00
RequestManagerUpdateTemplate ( const std : : string & method_name ,
const std : : string & help )
2012-06-13 19:41:54 +04:00
: Request ( method_name , " A:sis " , help )
2011-06-02 02:55:43 +04:00
{
auth_op = AuthRequest : : MANAGE ;
} ;
2024-06-03 12:40:24 +03:00
~ RequestManagerUpdateTemplate ( ) { } ;
2011-06-02 02:55:43 +04:00
/* -------------------------------------------------------------------- */
2011-07-07 14:45:13 +04:00
void request_execute ( xmlrpc_c : : paramList const & _paramList ,
2019-07-05 18:23:21 +03:00
RequestAttributes & att ) override ;
2013-03-12 18:19:00 +04:00
2024-01-08 15:56:40 +03:00
virtual void request_execute ( int oid ,
const std : : string & templ ,
int update_type ,
RequestAttributes & att ) ;
2020-07-02 23:42:10 +03:00
virtual int replace_template ( PoolObjectSQL * object ,
const std : : string & tmpl ,
const RequestAttributes & att ,
std : : string & error_str ) ;
2013-06-28 20:00:26 +04:00
2020-07-02 23:42:10 +03:00
virtual int append_template ( PoolObjectSQL * object ,
const std : : string & tmpl ,
const RequestAttributes & att ,
std : : string & error_str ) ;
2019-06-12 18:20:50 +03:00
/**
2021-10-08 20:27:06 +03:00
* Method for updating custom values not included in PoolSQL : : update
2019-06-12 18:20:50 +03:00
* mainly used for updating search information in the VMs .
2021-10-08 20:27:06 +03:00
* @ param obj to be updated
2019-06-12 18:20:50 +03:00
* @ return 0 on success
*/
virtual int extra_updates ( PoolObjectSQL * obj )
{
return 0 ;
2021-10-08 20:27:06 +03:00
}
2011-06-02 02:55:43 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class TemplateUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
2012-06-08 13:43:55 +04:00
TemplateUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.template.update " ,
2011-06-02 02:55:43 +04:00
" Updates a virtual machine template " )
2013-01-04 03:04:01 +04:00
{
2011-06-02 02:55:43 +04:00
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_tpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : TEMPLATE ;
2011-06-02 02:55:43 +04:00
} ;
2024-06-03 12:40:24 +03:00
~ TemplateUpdateTemplate ( ) { } ;
2011-06-02 02:55:43 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2018-11-20 19:24:59 +03:00
class VirtualNetworkTemplateUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
VirtualNetworkTemplateUpdateTemplate ( ) :
RequestManagerUpdateTemplate ( " one.vntemplate.update " ,
" Updates a virtual network template " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vntpool ( ) ;
auth_object = PoolObjectSQL : : VNTEMPLATE ;
} ;
2024-06-03 12:40:24 +03:00
~ VirtualNetworkTemplateUpdateTemplate ( ) { } ;
2018-11-20 19:24:59 +03:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2011-06-02 02:55:43 +04:00
2013-01-04 03:04:01 +04:00
class VirtualMachineUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
VirtualMachineUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.vm.update " ,
2013-01-04 03:04:01 +04:00
" Updates a virtual machine user template " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vmpool ( ) ;
auth_object = PoolObjectSQL : : VM ;
2019-09-09 14:13:52 +03:00
vm_action = VMActions : : UPDATE_ACTION ;
}
2017-01-30 15:46:05 +03:00
2019-09-09 14:13:52 +03:00
~ VirtualMachineUpdateTemplate ( ) = default ;
2019-06-12 18:20:50 +03:00
2019-09-09 14:13:52 +03:00
protected :
2024-01-08 15:56:40 +03:00
void request_execute ( int oid ,
const std : : string & templ ,
int update_type ,
RequestAttributes & att ) override ;
2013-01-04 03:04:01 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2011-06-02 02:55:43 +04:00
class ImageUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
ImageUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.image.update " ,
2011-06-02 02:55:43 +04:00
" Updates an image template " )
2013-01-04 03:04:01 +04:00
{
2011-06-02 02:55:43 +04:00
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_ipool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : IMAGE ;
2011-06-02 02:55:43 +04:00
} ;
2024-06-03 12:40:24 +03:00
~ ImageUpdateTemplate ( ) { } ;
2011-06-02 02:55:43 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class HostUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
HostUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.host.update " ,
2011-06-02 02:55:43 +04:00
" Updates a host template " )
2013-01-04 03:04:01 +04:00
{
2011-06-02 02:55:43 +04:00
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_hpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : HOST ;
2013-01-17 18:52:02 +04:00
auth_op = AuthRequest : : ADMIN ;
2011-06-02 02:55:43 +04:00
} ;
2024-06-03 12:40:24 +03:00
~ HostUpdateTemplate ( ) { } ;
2011-06-02 02:55:43 +04:00
} ;
2011-10-11 01:06:13 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class VirtualNetworkUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
VirtualNetworkUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.vn.update " ,
2011-10-11 01:06:13 +04:00
" Updates a vnet template " )
2013-01-04 03:04:01 +04:00
{
2011-10-11 01:06:13 +04:00
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vnpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : NET ;
2014-09-03 17:31:00 +04:00
auth_op = AuthRequest : : MANAGE ;
2011-10-11 01:06:13 +04:00
} ;
2024-06-03 12:40:24 +03:00
~ VirtualNetworkUpdateTemplate ( ) { } ;
2011-10-11 01:06:13 +04:00
} ;
2011-10-11 02:20:50 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class UserUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
UserUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.user.update " ,
2011-10-11 02:20:50 +04:00
" Updates a user template " )
2013-01-04 03:04:01 +04:00
{
2011-10-11 02:20:50 +04:00
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_upool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : USER ;
2011-10-11 02:20:50 +04:00
} ;
2024-06-03 12:40:24 +03:00
~ UserUpdateTemplate ( ) { } ;
2011-10-11 02:20:50 +04:00
} ;
2012-03-02 20:25:42 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DatastoreUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
DatastoreUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.datastore.update " ,
2012-03-02 20:25:42 +04:00
" Updates a datastore template " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_dspool ( ) ;
auth_object = PoolObjectSQL : : DATASTORE ;
} ;
2024-06-03 12:40:24 +03:00
~ DatastoreUpdateTemplate ( ) { } ;
2012-03-02 20:25:42 +04:00
} ;
2012-06-08 18:00:16 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DocumentUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
DocumentUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.document.update " ,
2012-06-13 19:41:54 +04:00
" Updates a document template " )
2012-06-08 18:00:16 +04:00
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_docpool ( ) ;
auth_object = PoolObjectSQL : : DOCUMENT ;
} ;
2024-06-03 12:40:24 +03:00
~ DocumentUpdateTemplate ( ) { } ;
2012-06-08 18:00:16 +04:00
} ;
2012-06-28 19:51:21 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class ClusterUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
ClusterUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.cluster.update " ,
2012-06-28 19:51:21 +04:00
" Updates a cluster template " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_clpool ( ) ;
auth_object = PoolObjectSQL : : CLUSTER ;
} ;
2024-06-03 12:40:24 +03:00
~ ClusterUpdateTemplate ( ) { } ;
2020-03-04 18:05:57 +03:00
protected :
int extra_updates ( PoolObjectSQL * obj ) override ;
2012-06-28 19:51:21 +04:00
} ;
2014-01-13 21:26:21 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class ZoneUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
ZoneUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.zone.update " ,
2014-01-13 21:26:21 +04:00
" Updates a zone template " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_zonepool ( ) ;
auth_object = PoolObjectSQL : : ZONE ;
} ;
2024-06-03 12:40:24 +03:00
~ ZoneUpdateTemplate ( ) { } ;
2014-01-13 21:26:21 +04:00
} ;
2014-02-26 15:59:03 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class GroupUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
GroupUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.group.update " ,
2014-02-26 15:59:03 +04:00
" Updates a Group template " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_gpool ( ) ;
auth_object = PoolObjectSQL : : GROUP ;
} ;
2024-06-03 12:40:24 +03:00
~ GroupUpdateTemplate ( ) { } ;
2014-02-26 15:59:03 +04:00
} ;
2014-09-08 13:50:25 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class SecurityGroupUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
SecurityGroupUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.secgroup.update " ,
2014-09-08 13:50:25 +04:00
" Updates a security group template " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_secgrouppool ( ) ;
auth_object = PoolObjectSQL : : SECGROUP ;
} ;
2024-06-03 12:40:24 +03:00
~ SecurityGroupUpdateTemplate ( ) { } ;
2014-09-08 13:50:25 +04:00
} ;
2014-12-19 19:30:00 +03:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class VdcUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
VdcUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.vdc.update " ,
2014-12-19 19:30:00 +03:00
" Updates a VDC template " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vdcpool ( ) ;
auth_object = PoolObjectSQL : : VDC ;
} ;
2024-06-03 12:40:24 +03:00
~ VdcUpdateTemplate ( ) { } ;
2014-12-19 19:30:00 +03:00
} ;
2015-11-30 18:50:23 +03:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class VirtualRouterUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
VirtualRouterUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.vrouter.update " ,
2015-11-30 18:50:23 +03:00
" Updates a virtual router template " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vrouterpool ( ) ;
auth_object = PoolObjectSQL : : VROUTER ;
} ;
2024-06-03 12:40:24 +03:00
~ VirtualRouterUpdateTemplate ( ) { } ;
2015-11-30 18:50:23 +03:00
} ;
2015-12-06 01:52:28 +03:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class MarketPlaceUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
MarketPlaceUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.market.update " ,
2015-12-11 17:53:19 +03:00
" Updates a marketplace template " )
2015-12-06 01:52:28 +03:00
{
Nebula & nd = Nebula : : instance ( ) ;
2015-12-11 17:53:19 +03:00
pool = nd . get_marketpool ( ) ;
2015-12-06 01:52:28 +03:00
auth_object = PoolObjectSQL : : MARKETPLACE ;
} ;
2024-06-03 12:40:24 +03:00
~ MarketPlaceUpdateTemplate ( ) { } ;
2015-12-06 01:52:28 +03:00
} ;
2015-12-11 17:53:19 +03:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class MarketPlaceAppUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
MarketPlaceAppUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.marketapp.update " ,
2015-12-11 17:53:19 +03:00
" Updates a marketplace app template " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_apppool ( ) ;
auth_object = PoolObjectSQL : : MARKETPLACEAPP ;
} ;
2024-06-03 12:40:24 +03:00
~ MarketPlaceAppUpdateTemplate ( ) { } ;
2015-12-11 17:53:19 +03:00
} ;
2011-06-02 02:55:43 +04:00
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
2017-01-03 23:12:27 +03:00
class VMGroupUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
VMGroupUpdateTemplate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUpdateTemplate ( " one.vmgroup.update " ,
2017-01-03 23:12:27 +03:00
" Updates a vm group template " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vmgrouppool ( ) ;
auth_object = PoolObjectSQL : : VMGROUP ;
} ;
2024-06-03 12:40:24 +03:00
~ VMGroupUpdateTemplate ( ) { } ;
2017-01-03 23:12:27 +03:00
} ;
2019-09-09 15:43:51 +03:00
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class HookUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
HookUpdateTemplate ( ) :
RequestManagerUpdateTemplate ( " one.hook.update " ,
" Updates a hook template " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_hkpool ( ) ;
auth_object = PoolObjectSQL : : HOOK ;
} ;
2024-06-03 12:40:24 +03:00
~ HookUpdateTemplate ( ) { } ;
2019-09-09 15:43:51 +03:00
} ;
2023-07-03 19:15:52 +03:00
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class BackupJobUpdateTemplate : public RequestManagerUpdateTemplate
{
public :
BackupJobUpdateTemplate ( ) :
RequestManagerUpdateTemplate ( " one.backupjob.update " ,
" Updates a Backup Job template " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_bjpool ( ) ;
auth_object = PoolObjectSQL : : BACKUPJOB ;
}
} ;
2011-06-02 02:55:43 +04:00
# endif