2011-06-02 02:55:43 +04:00
/* -------------------------------------------------------------------------- */
2019-01-16 13:27:59 +03:00
/* Copyright 2002-2019, 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"
using namespace std ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class RequestManagerUpdateTemplate : public Request
{
protected :
RequestManagerUpdateTemplate ( const string & method_name ,
2012-06-13 19:41:54 +04:00
const string & help )
: Request ( method_name , " A:sis " , help )
2011-06-02 02:55:43 +04:00
{
auth_op = AuthRequest : : MANAGE ;
} ;
~ RequestManagerUpdateTemplate ( ) { } ;
/* -------------------------------------------------------------------- */
2011-07-07 14:45:13 +04:00
void request_execute ( xmlrpc_c : : paramList const & _paramList ,
RequestAttributes & att ) ;
2013-03-12 18:19:00 +04:00
virtual int replace_template ( PoolObjectSQL * object , const string & tmpl ,
const RequestAttributes & att , string & error_str ) ;
2013-06-28 20:00:26 +04:00
virtual int append_template ( PoolObjectSQL * object , const string & tmpl ,
const RequestAttributes & att , string & error_str ) ;
2019-06-12 18:20:50 +03:00
/**
* Method por updating custom values not included in PoolSQL : : update
* mainly used for updating search information in the VMs .
* @ param object to be updated
* @ return 0 on success
*/
virtual int extra_updates ( PoolObjectSQL * obj )
{
return 0 ;
} ;
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
} ;
~ TemplateUpdateTemplate ( ) { } ;
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
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 ;
} ;
~ VirtualNetworkTemplateUpdateTemplate ( ) { } ;
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
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 ;
2017-01-30 15:46:05 +03:00
auth_op = nd . get_vm_auth_op ( History : : UPDATE_ACTION ) ;
2013-01-04 03:04:01 +04:00
} ;
~ VirtualMachineUpdateTemplate ( ) { } ;
2019-06-12 18:20:50 +03:00
int extra_updates ( PoolObjectSQL * obj )
{
VirtualMachine * vm ;
VirtualMachinePool * vmpool = static_cast < VirtualMachinePool * > ( pool ) ;
if ( obj = = 0 )
{
return - 1 ;
}
vm = static_cast < VirtualMachine * > ( obj ) ;
return vmpool - > update_search ( vm ) ;
} ;
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
} ;
~ ImageUpdateTemplate ( ) { } ;
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
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
} ;
~ HostUpdateTemplate ( ) { } ;
} ;
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
} ;
~ VirtualNetworkUpdateTemplate ( ) { } ;
} ;
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
} ;
~ UserUpdateTemplate ( ) { } ;
} ;
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 ;
} ;
~ DatastoreUpdateTemplate ( ) { } ;
} ;
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 ;
} ;
~ DocumentUpdateTemplate ( ) { } ;
} ;
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 ;
} ;
~ ClusterUpdateTemplate ( ) { } ;
} ;
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 ;
} ;
~ ZoneUpdateTemplate ( ) { } ;
} ;
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 ;
} ;
~ GroupUpdateTemplate ( ) { } ;
} ;
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 ;
} ;
~ SecurityGroupUpdateTemplate ( ) { } ;
} ;
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 ;
} ;
~ VdcUpdateTemplate ( ) { } ;
} ;
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 ;
} ;
~ VirtualRouterUpdateTemplate ( ) { } ;
} ;
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 ;
} ;
~ MarketPlaceUpdateTemplate ( ) { } ;
} ;
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 ;
} ;
~ MarketPlaceAppUpdateTemplate ( ) { } ;
} ;
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 ;
} ;
~ VMGroupUpdateTemplate ( ) { } ;
} ;
2011-06-02 02:55:43 +04:00
# endif