2011-05-26 02:59:50 +04:00
/* -------------------------------------------------------------------------- */
2018-01-02 20:27:37 +03:00
/* Copyright 2002-2018, OpenNebula Project, OpenNebula Systems */
2011-05-26 02:59:50 +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_DELETE_H_
# define REQUEST_MANAGER_DELETE_H_
# include "Request.h"
# include "Nebula.h"
# include "AuthManager.h"
using namespace std ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class RequestManagerDelete : public Request
{
protected :
2016-02-08 18:40:38 +03:00
RequestManagerDelete ( const string & method_name ,
const string & params ,
const string & help )
: Request ( method_name , params , help )
{
auth_op = AuthRequest : : MANAGE ;
Nebula & nd = Nebula : : instance ( ) ;
clpool = nd . get_clpool ( ) ;
aclm = nd . get_aclm ( ) ;
} ;
2011-05-26 02:59:50 +04:00
RequestManagerDelete ( const string & method_name ,
2012-06-13 19:41:54 +04:00
const string & help )
: Request ( method_name , " A:si " , help )
2012-01-05 05:39:00 +04:00
{
auth_op = AuthRequest : : MANAGE ;
2012-02-29 20:00:33 +04:00
2012-03-01 20:14:52 +04:00
Nebula & nd = Nebula : : instance ( ) ;
clpool = nd . get_clpool ( ) ;
2012-04-16 18:24:42 +04:00
aclm = nd . get_aclm ( ) ;
2012-01-05 05:39:00 +04:00
} ;
2011-05-26 02:59:50 +04:00
~ RequestManagerDelete ( ) { } ;
2016-02-08 18:40:38 +03:00
void request_execute ( xmlrpc_c : : paramList const & paramList ,
2016-04-21 17:08:28 +03:00
RequestAttributes & att ) ;
2011-06-10 20:22:48 +04:00
2016-04-21 17:08:28 +03:00
ErrorCode delete_object ( int oid , bool recursive ,
RequestAttributes & att ) ;
2013-10-25 19:52:56 +04:00
2011-06-10 20:22:48 +04:00
/* -------------------------------------------------------------------- */
2016-04-21 17:08:28 +03:00
virtual int drop ( PoolObjectSQL * obj , bool resive , RequestAttributes & att ) ;
2011-06-10 20:22:48 +04:00
2016-03-10 18:28:33 +03:00
virtual set < int > get_cluster_ids ( PoolObjectSQL * object )
2012-02-29 20:00:33 +04:00
{
2016-03-10 18:28:33 +03:00
set < int > empty ;
return empty ;
2012-02-29 20:00:33 +04:00
} ;
2011-06-10 20:22:48 +04:00
2012-02-29 20:00:33 +04:00
virtual int del_from_cluster ( Cluster * cluster , int id , string & error_msg )
{
return - 1 ;
2011-06-10 20:22:48 +04:00
} ;
2016-04-21 17:08:28 +03:00
/* -------------------------------------------------------------------- */
ClusterPool * clpool ;
AclManager * aclm ;
2011-05-26 02:59:50 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2011-05-26 14:20:56 +04:00
class TemplateDelete : public RequestManagerDelete
2011-05-26 02:59:50 +04:00
{
public :
2012-06-08 13:43:55 +04:00
TemplateDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.template.delete " ,
2016-02-08 18:40:38 +03:00
" A:sib "
2011-05-26 02:59:50 +04:00
" Deletes a virtual machine template " )
2011-12-28 20:51:10 +04:00
{
2011-05-26 02:59:50 +04:00
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_tpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : TEMPLATE ;
2011-05-26 02:59:50 +04:00
} ;
~ TemplateDelete ( ) { } ;
2016-02-08 18:40:38 +03:00
2016-04-21 17:08:28 +03:00
ErrorCode request_execute ( int oid , bool recursive , RequestAttributes & att )
{
return delete_object ( oid , recursive , att ) ;
}
protected :
2016-04-11 13:25:02 +03:00
2016-04-21 17:08:28 +03:00
int drop ( PoolObjectSQL * obj , bool resive , RequestAttributes & att ) ;
2011-05-26 02:59:50 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2011-05-26 14:20:56 +04:00
class VirtualNetworkDelete : public RequestManagerDelete
2011-05-26 02:59:50 +04:00
{
public :
VirtualNetworkDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.vn.delete " ,
2012-03-01 20:14:52 +04:00
" Deletes a virtual network " )
2013-10-25 19:52:56 +04:00
{
2011-05-26 02:59:50 +04:00
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vnpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : NET ;
2011-05-26 02:59:50 +04:00
} ;
~ VirtualNetworkDelete ( ) { } ;
2012-02-29 21:09:47 +04:00
2016-04-21 17:08:28 +03:00
protected :
2012-02-29 21:09:47 +04:00
2016-03-10 18:28:33 +03:00
set < int > get_cluster_ids ( PoolObjectSQL * object )
2012-02-29 21:09:47 +04:00
{
2016-03-10 18:28:33 +03:00
return static_cast < VirtualNetwork * > ( object ) - > get_cluster_ids ( ) ;
2012-02-29 21:09:47 +04:00
} ;
int del_from_cluster ( Cluster * cluster , int id , string & error_msg )
{
return cluster - > del_vnet ( id , error_msg ) ;
} ;
2014-03-19 20:09:52 +04:00
2016-04-21 17:08:28 +03:00
int drop ( PoolObjectSQL * obj , bool resive , RequestAttributes & att ) ;
2011-05-26 02:59:50 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2011-05-26 14:20:56 +04:00
class ImageDelete : public RequestManagerDelete
2011-05-26 02:59:50 +04:00
{
public :
ImageDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.image.delete " , " Deletes an image " )
2013-10-25 19:52:56 +04:00
{
2011-05-26 02:59:50 +04:00
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_ipool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : IMAGE ;
2011-05-26 02:59:50 +04:00
} ;
~ ImageDelete ( ) { } ;
2011-06-10 20:22:48 +04:00
2016-04-21 17:08:28 +03:00
ErrorCode request_execute ( int oid , RequestAttributes & att )
{
return delete_object ( oid , false , att ) ;
} ;
protected :
2016-02-08 18:40:38 +03:00
2016-04-21 17:08:28 +03:00
int drop ( PoolObjectSQL * obj , bool resive , RequestAttributes & att ) ;
2011-05-26 02:59:50 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class HostDelete : public RequestManagerDelete
{
public :
HostDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.host.delete " , " Deletes a host " )
2013-10-25 19:52:56 +04:00
{
2011-05-26 02:59:50 +04:00
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_hpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : HOST ;
2012-01-12 15:07:03 +04:00
auth_op = AuthRequest : : ADMIN ;
2011-05-26 02:59:50 +04:00
} ;
~ HostDelete ( ) { } ;
2012-02-28 20:25:02 +04:00
2016-04-21 17:08:28 +03:00
protected :
2012-02-28 20:25:02 +04:00
2016-03-10 18:28:33 +03:00
set < int > get_cluster_ids ( PoolObjectSQL * object )
2012-02-29 20:00:33 +04:00
{
2016-03-15 18:37:36 +03:00
set < int > ids ;
ids . insert ( static_cast < Host * > ( object ) - > get_cluster_id ( ) ) ;
return ids ;
2012-02-29 20:00:33 +04:00
} ;
int del_from_cluster ( Cluster * cluster , int id , string & error_msg )
{
return cluster - > del_host ( id , error_msg ) ;
} ;
2013-10-25 19:52:56 +04:00
2016-04-21 17:08:28 +03:00
int drop ( PoolObjectSQL * obj , bool resive , RequestAttributes & att ) ;
2011-05-26 02:59:50 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class GroupDelete : public RequestManagerDelete
{
public :
GroupDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.group.delete " , " Deletes a group " )
2013-10-25 19:52:56 +04:00
{
2011-05-26 02:59:50 +04:00
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_gpool ( ) ;
2012-04-11 16:45:46 +04:00
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : GROUP ;
2012-01-12 15:07:03 +04:00
auth_op = AuthRequest : : ADMIN ;
2011-05-26 02:59:50 +04:00
} ;
~ GroupDelete ( ) { } ;
2012-04-11 16:45:46 +04:00
2016-04-21 17:08:28 +03:00
protected :
2012-04-11 16:45:46 +04:00
2016-04-21 17:08:28 +03:00
int drop ( PoolObjectSQL * obj , bool resive , RequestAttributes & att ) ;
2011-05-26 02:59:50 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class UserDelete : public RequestManagerDelete
{
public :
UserDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.user.delete " , " Deletes a user " )
2013-10-25 19:52:56 +04:00
{
2011-05-26 02:59:50 +04:00
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_upool ( ) ;
2012-04-11 16:45:46 +04:00
gpool = nd . get_gpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : USER ;
2012-01-12 15:07:03 +04:00
auth_op = AuthRequest : : ADMIN ;
2011-05-26 02:59:50 +04:00
} ;
~ UserDelete ( ) { } ;
2011-07-21 13:57:04 +04:00
2016-04-21 17:08:28 +03:00
protected :
2011-07-21 13:57:04 +04:00
2012-04-11 16:45:46 +04:00
GroupPool * gpool ;
2016-04-21 17:08:28 +03:00
int drop ( PoolObjectSQL * obj , bool resive , RequestAttributes & att ) ;
2011-05-26 02:59:50 +04:00
} ;
2012-02-09 20:56:47 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DatastoreDelete : public RequestManagerDelete
{
public :
DatastoreDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.datastore.delete " , " Deletes a datastore " )
2012-02-09 20:56:47 +04:00
{
Nebula & nd = Nebula : : instance ( ) ;
2012-02-10 16:27:26 +04:00
pool = nd . get_dspool ( ) ;
2012-02-09 20:56:47 +04:00
auth_object = PoolObjectSQL : : DATASTORE ;
auth_op = AuthRequest : : ADMIN ;
} ;
~ DatastoreDelete ( ) { } ;
2012-02-29 20:00:33 +04:00
/* -------------------------------------------------------------------- */
2016-03-10 18:28:33 +03:00
set < int > get_cluster_ids ( PoolObjectSQL * object )
2012-02-29 20:00:33 +04:00
{
2016-03-10 18:28:33 +03:00
return static_cast < Datastore * > ( object ) - > get_cluster_ids ( ) ;
2012-02-29 20:00:33 +04:00
} ;
int del_from_cluster ( Cluster * cluster , int id , string & error_msg )
{
return cluster - > del_datastore ( id , error_msg ) ;
} ;
2012-02-09 20:56:47 +04:00
} ;
2012-02-24 18:53:53 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class ClusterDelete : public RequestManagerDelete
{
public :
ClusterDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.cluster.delete " , " Deletes a cluster " )
2012-02-24 18:53:53 +04:00
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_clpool ( ) ;
auth_object = PoolObjectSQL : : CLUSTER ;
auth_op = AuthRequest : : ADMIN ;
} ;
~ ClusterDelete ( ) { } ;
2013-01-23 19:46:14 +04:00
2016-04-21 17:08:28 +03:00
protected :
int drop ( PoolObjectSQL * obj , bool resive , RequestAttributes & att ) ;
2012-02-24 18:53:53 +04:00
} ;
2012-06-08 18:00:16 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DocumentDelete : public RequestManagerDelete
{
public :
DocumentDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.document.delete " ,
2012-06-13 19:41:54 +04:00
" Deletes a generic document " )
2012-06-08 18:00:16 +04:00
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_docpool ( ) ;
auth_object = PoolObjectSQL : : DOCUMENT ;
} ;
~ DocumentDelete ( ) { } ;
} ;
2013-12-12 22:08:59 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class ZoneDelete : public RequestManagerDelete
{
public :
ZoneDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.zone.delete " , " Deletes a zone " )
2013-12-12 22:08:59 +04:00
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_zonepool ( ) ;
auth_object = PoolObjectSQL : : ZONE ;
auth_op = AuthRequest : : ADMIN ;
} ;
~ ZoneDelete ( ) { } ;
2014-02-21 18:23:24 +04:00
2016-04-21 17:08:28 +03:00
protected :
int drop ( PoolObjectSQL * obj , bool resive , RequestAttributes & att ) ;
2013-12-12 22:08:59 +04:00
} ;
2014-09-08 13:50:25 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class SecurityGroupDelete : public RequestManagerDelete
{
public :
SecurityGroupDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.secgroup.delete " ,
2014-09-08 13:50:25 +04:00
" Deletes a security group " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_secgrouppool ( ) ;
auth_object = PoolObjectSQL : : SECGROUP ;
} ;
~ SecurityGroupDelete ( ) { } ;
2014-09-09 20:13:52 +04:00
2016-04-21 17:08:28 +03:00
protected :
int drop ( PoolObjectSQL * obj , bool resive , RequestAttributes & att ) ;
2014-09-08 13:50:25 +04:00
} ;
2014-12-19 19:30:00 +03:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class VdcDelete : public RequestManagerDelete
{
public :
VdcDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.vdc.delete " , " Deletes a VDC " )
2014-12-19 19:30:00 +03:00
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vdcpool ( ) ;
auth_object = PoolObjectSQL : : VDC ;
auth_op = AuthRequest : : ADMIN ;
} ;
~ VdcDelete ( ) { } ;
} ;
2015-11-30 18:50:23 +03:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class VirtualRouterDelete : public RequestManagerDelete
{
public :
VirtualRouterDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.vrouter.delete " ,
2015-11-30 18:50:23 +03:00
" Deletes a virtual router " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vrouterpool ( ) ;
auth_object = PoolObjectSQL : : VROUTER ;
} ;
~ VirtualRouterDelete ( ) { } ;
2017-02-07 19:26:23 +03:00
protected :
int drop ( PoolObjectSQL * obj , bool resive , RequestAttributes & att ) ;
2015-11-30 18:50:23 +03:00
} ;
2015-12-06 01:52:28 +03:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class MarketPlaceDelete : public RequestManagerDelete
{
public :
MarketPlaceDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.market.delete " ,
2015-12-06 01:52:28 +03:00
" Deletes a marketplace " )
{
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 ;
} ;
~ MarketPlaceDelete ( ) { } ;
2016-02-29 20:19:52 +03:00
2016-04-21 17:08:28 +03:00
protected :
int drop ( PoolObjectSQL * obj , bool resive , RequestAttributes & att ) ;
2015-12-06 01:52:28 +03:00
} ;
2015-12-11 17:53:19 +03:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class MarketPlaceAppDelete : public RequestManagerDelete
{
public :
MarketPlaceAppDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.marketapp.delete " ,
2015-12-11 17:53:19 +03:00
" Deletes a marketplace app " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_apppool ( ) ;
auth_object = PoolObjectSQL : : MARKETPLACEAPP ;
} ;
~ MarketPlaceAppDelete ( ) { } ;
2015-12-21 15:23:22 +03:00
2016-04-21 17:08:28 +03:00
protected :
int drop ( PoolObjectSQL * obj , bool resive , RequestAttributes & att ) ;
2015-12-11 17:53:19 +03:00
} ;
2017-01-03 03:22:10 +03:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class VMGroupDelete : public RequestManagerDelete
{
public :
VMGroupDelete ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerDelete ( " one.vmgroup.delete " ,
2017-01-03 03:22:10 +03:00
" Deletes a vm group " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vmgrouppool ( ) ;
auth_object = PoolObjectSQL : : VMGROUP ;
} ;
~ VMGroupDelete ( ) { } ;
} ;
2011-05-26 02:59:50 +04:00
# endif
2017-01-03 03:22:10 +03:00