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