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