2011-05-26 00:59:50 +02:00
/* -------------------------------------------------------------------------- */
2014-01-09 11:51:20 +01:00
/* Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs */
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 :
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 ( ) { } ;
/* -------------------------------------------------------------------- */
2011-07-07 12:45:13 +02:00
void request_execute ( xmlrpc_c : : paramList const & _paramList ,
RequestAttributes & att ) ;
2011-06-10 18:22:48 +02:00
2012-06-08 16:00:16 +02:00
bool delete_authorization ( int oid ,
2012-06-13 12:44:04 +02:00
RequestAttributes & att ) ;
2013-10-25 17:52:56 +02:00
2011-06-10 18:22:48 +02:00
/* -------------------------------------------------------------------- */
2012-02-29 17:00:33 +01:00
virtual int drop ( int oid , PoolObjectSQL * object , string & error_msg ) ;
2011-06-10 18:22:48 +02:00
2012-02-29 17:00:33 +01:00
virtual int get_cluster_id ( PoolObjectSQL * object )
{
2012-03-01 17:14:52 +01:00
return ClusterPool : : NONE_CLUSTER_ID ;
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
} ;
2012-04-16 16:24:42 +02:00
protected :
2012-02-29 17:00:33 +01:00
ClusterPool * clpool ;
2012-04-16 16:24:42 +02:00
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 ( ) :
2011-05-26 00:59:50 +02:00
RequestManagerDelete ( " TemplateDelete " ,
" 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 ( ) { } ;
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2011-05-26 12:20:56 +02:00
class VirtualNetworkDelete : public RequestManagerDelete
2011-05-26 00:59:50 +02:00
{
public :
VirtualNetworkDelete ( ) :
RequestManagerDelete ( " VirtualNetworkDelete " ,
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
/* -------------------------------------------------------------------- */
int get_cluster_id ( PoolObjectSQL * object )
{
return static_cast < VirtualNetwork * > ( object ) - > get_cluster_id ( ) ;
} ;
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
int drop ( int oid , PoolObjectSQL * object , string & error_msg ) ;
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 ( ) :
RequestManagerDelete ( " ImageDelete " , " 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
/* -------------------------------------------------------------------- */
int drop ( int oid , PoolObjectSQL * object , string & error_msg ) ;
2011-05-26 00:59:50 +02:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class HostDelete : public RequestManagerDelete
{
public :
HostDelete ( ) :
2012-03-01 17:14:52 +01:00
RequestManagerDelete ( " HostDelete " , " 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
/* -------------------------------------------------------------------- */
2012-02-29 17:00:33 +01:00
int get_cluster_id ( PoolObjectSQL * object )
{
return static_cast < Host * > ( object ) - > get_cluster_id ( ) ;
} ;
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
/* -------------------------------------------------------------------- */
int drop ( int oid , PoolObjectSQL * object , string & error_msg ) ;
2011-05-26 00:59:50 +02:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class GroupDelete : public RequestManagerDelete
{
public :
GroupDelete ( ) :
RequestManagerDelete ( " GroupDelete " , " 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
/* -------------------------------------------------------------------- */
int drop ( int oid , PoolObjectSQL * object , string & error_msg ) ;
2011-05-26 00:59:50 +02:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class UserDelete : public RequestManagerDelete
{
public :
UserDelete ( ) :
RequestManagerDelete ( " UserDelete " , " 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
/* -------------------------------------------------------------------- */
2012-04-11 14:45:46 +02:00
GroupPool * gpool ;
/* -------------------------------------------------------------------- */
2011-07-21 02:57:04 -07:00
int drop ( int oid , PoolObjectSQL * object , string & error_msg ) ;
2011-05-26 00:59:50 +02:00
} ;
2012-02-09 17:56:47 +01:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DatastoreDelete : public RequestManagerDelete
{
public :
DatastoreDelete ( ) :
2012-03-01 17:14:52 +01:00
RequestManagerDelete ( " DatastoreDelete " , " 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
/* -------------------------------------------------------------------- */
int get_cluster_id ( PoolObjectSQL * object )
{
return static_cast < Datastore * > ( object ) - > get_cluster_id ( ) ;
} ;
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 ( ) :
RequestManagerDelete ( " ClusterDelete " , " Deletes a cluster " )
{
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
int drop ( int oid , PoolObjectSQL * object , string & error_msg ) ;
2012-02-24 15:53:53 +01:00
} ;
2012-06-08 16:00:16 +02:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DocumentDelete : public RequestManagerDelete
{
public :
DocumentDelete ( ) :
RequestManagerDelete ( " DocumentDelete " ,
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 ( ) :
RequestManagerDelete ( " ZoneDelete " , " Deletes a zone " )
{
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
int drop ( int oid , PoolObjectSQL * object , string & error_msg ) ;
2013-12-12 19:08:59 +01:00
} ;
2014-09-08 11:50:25 +02:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class SecurityGroupDelete : public RequestManagerDelete
{
public :
SecurityGroupDelete ( ) :
RequestManagerDelete ( " SecurityGroupDelete " ,
" 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
int drop ( int oid , PoolObjectSQL * object , string & error_msg ) ;
2014-09-08 11:50:25 +02:00
} ;
2011-05-26 00:59:50 +02:00
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
# endif