2016-03-08 16:38:51 +01:00
/* -------------------------------------------------------------------------- */
2021-02-09 16:07:56 +01:00
/* Copyright 2002-2021, OpenNebula Project, OpenNebula Systems */
2016-03-08 16:38:51 +01: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_ALLOCATE_DB_H
# define REQUEST_MANAGER_ALLOCATE_DB_H
# include "Request.h"
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class RequestManagerAllocateDB : public Request
{
protected :
2020-07-02 22:42:10 +02:00
RequestManagerAllocateDB ( const std : : string & name ) : Request ( name , " A:ss " ,
2016-03-08 16:38:51 +01:00
" Allocates a new object from its template representation " )
{
auth_op = AuthRequest : : MANAGE ;
} ;
2019-07-05 17:23:21 +02:00
~ RequestManagerAllocateDB ( ) { } ;
2016-03-08 16:38:51 +01:00
virtual PoolObjectSQL * create ( const std : : string & xml ) = 0 ;
/* -------------------------------------------------------------------- */
2019-07-05 17:23:21 +02:00
void request_execute ( xmlrpc_c : : paramList const & pl , RequestAttributes & att ) override
2016-03-08 16:38:51 +01:00
{
std : : string xml = xmlrpc_c : : value_string ( pl . getString ( 1 ) ) ;
2018-05-23 14:42:57 +02:00
if ( ! att . is_oneadmin ( ) )
2016-03-08 16:38:51 +01:00
{
failure_response ( AUTHORIZATION , att ) ;
return ;
}
PoolObjectSQL * obj = create ( xml ) ;
int rc = pool - > allocate ( obj , att . resp_msg ) ;
if ( rc = = - 1 )
{
failure_response ( INTERNAL , att ) ;
return ;
}
success_response ( rc , att ) ;
return ;
}
} ;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class MarketPlaceAppAllocateDB : public RequestManagerAllocateDB
{
public :
2017-05-07 21:52:34 +02:00
MarketPlaceAppAllocateDB ( ) : RequestManagerAllocateDB ( " one.marketapp.allocatedb " )
2016-03-08 16:38:51 +01:00
{
auth_object = PoolObjectSQL : : MARKETPLACEAPP ;
pool = Nebula : : instance ( ) . get_apppool ( ) ;
} ;
2019-07-05 17:23:21 +02:00
~ MarketPlaceAppAllocateDB ( ) { } ;
2016-03-08 16:38:51 +01:00
/* -------------------------------------------------------------------- */
2019-07-05 17:23:21 +02:00
PoolObjectSQL * create ( const std : : string & xml ) override
2016-03-08 16:38:51 +01:00
{
PoolObjectSQL * app = static_cast < MarketPlaceAppPool * > ( pool ) - > create ( ) ;
app - > from_xml ( xml ) ;
return app ;
}
} ;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class MarketPlaceAllocateDB : public RequestManagerAllocateDB
{
public :
2017-05-07 21:52:34 +02:00
MarketPlaceAllocateDB ( ) : RequestManagerAllocateDB ( " one.market.allocatedb " )
2016-03-08 16:38:51 +01:00
{
auth_object = PoolObjectSQL : : MARKETPLACE ;
pool = Nebula : : instance ( ) . get_marketpool ( ) ;
} ;
2019-07-05 17:23:21 +02:00
~ MarketPlaceAllocateDB ( ) { } ;
2016-03-08 16:38:51 +01:00
/* -------------------------------------------------------------------- */
2019-07-05 17:23:21 +02:00
PoolObjectSQL * create ( const std : : string & xml ) override
2016-03-08 16:38:51 +01:00
{
PoolObjectSQL * mp = static_cast < MarketPlacePool * > ( pool ) - > create ( ) ;
mp - > from_xml ( xml ) ;
return mp ;
}
} ;
# endif /* REQUEST_MANAGER_ALLOCATE_DB_H */