2011-05-28 06:03:09 +04:00
/* -------------------------------------------------------------------------- */
2012-01-12 15:29:18 +04:00
/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */
2011-05-28 06:03:09 +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_ALLOCATE_H_
# define REQUEST_MANAGER_ALLOCATE_H_
# include "Request.h"
# include "Nebula.h"
# include "VirtualNetworkTemplate.h"
# include "ImageTemplate.h"
# include "VirtualMachineTemplate.h"
using namespace std ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class RequestManagerAllocate : public Request
{
protected :
RequestManagerAllocate ( const string & method_name ,
const string & help ,
const string & xml_args ,
bool dt )
: Request ( method_name , xml_args , help ) , do_template ( dt )
{
auth_op = AuthRequest : : CREATE ;
} ;
~ RequestManagerAllocate ( ) { } ;
/* -------------------------------------------------------------------- */
2011-07-07 14:45:13 +04:00
void request_execute ( xmlrpc_c : : paramList const & _paramList ,
RequestAttributes & att ) ;
2011-05-28 06:03:09 +04:00
2011-07-07 14:45:13 +04:00
virtual bool allocate_authorization ( Template * obj_template ,
RequestAttributes & att ) ;
2011-05-28 06:03:09 +04:00
/* -------------------------------------------------------------------- */
virtual Template * get_object_template ( ) { return 0 ; } ;
virtual int pool_allocate ( xmlrpc_c : : paramList const & _paramList ,
Template * tmpl ,
int & id ,
2011-07-07 14:45:13 +04:00
string & error_str ,
RequestAttributes & att ) = 0 ;
2011-05-28 06:03:09 +04:00
private :
bool do_template ;
} ;
2011-06-01 14:37:39 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class VirtualMachineAllocate : public RequestManagerAllocate
{
public :
VirtualMachineAllocate ( ) :
RequestManagerAllocate ( " VirtualMachineAllocate " ,
" Allocates a new virtual machine " ,
" A:ss " ,
true )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vmpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : VM ;
2011-06-01 14:37:39 +04:00
} ;
~ VirtualMachineAllocate ( ) { } ;
/* --------------------------------------------------------------------- */
Template * get_object_template ( )
{
return new VirtualMachineTemplate ;
} ;
int pool_allocate ( xmlrpc_c : : paramList const & _paramList ,
Template * tmpl ,
int & id ,
2011-07-07 14:45:13 +04:00
string & error_str ,
RequestAttributes & att ) ;
2011-06-01 14:37:39 +04:00
2011-07-07 14:45:13 +04:00
bool allocate_authorization ( Template * obj_template ,
RequestAttributes & att ) ;
2011-06-01 14:37:39 +04:00
} ;
2011-05-28 06:03:09 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class VirtualNetworkAllocate : public RequestManagerAllocate
{
public :
VirtualNetworkAllocate ( ) :
2011-06-29 14:50:16 +04:00
RequestManagerAllocate ( " VirtualNetworkAllocate " ,
2011-05-28 06:03:09 +04:00
" Allocates a new virtual network " ,
" A:ss " ,
true )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vnpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : NET ;
2011-05-28 06:03:09 +04:00
} ;
~ VirtualNetworkAllocate ( ) { } ;
/* --------------------------------------------------------------------- */
Template * get_object_template ( )
{
return new VirtualNetworkTemplate ;
} ;
int pool_allocate ( xmlrpc_c : : paramList const & _paramList ,
Template * tmpl ,
int & id ,
2011-07-07 14:45:13 +04:00
string & error_str ,
RequestAttributes & att ) ;
2011-05-28 06:03:09 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class ImageAllocate : public RequestManagerAllocate
{
public :
ImageAllocate ( ) :
RequestManagerAllocate ( " ImageAllocate " ,
" Allocates a new image " ,
" A:ss " ,
true )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_ipool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : IMAGE ;
2011-05-28 06:03:09 +04:00
} ;
~ ImageAllocate ( ) { } ;
/* --------------------------------------------------------------------- */
Template * get_object_template ( )
{
return new ImageTemplate ;
} ;
int pool_allocate ( xmlrpc_c : : paramList const & _paramList ,
Template * tmpl ,
int & id ,
2011-07-07 14:45:13 +04:00
string & error_str ,
RequestAttributes & att ) ;
2011-05-28 06:03:09 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class TemplateAllocate : public RequestManagerAllocate
{
public :
TemplateAllocate ( ) :
RequestManagerAllocate ( " TemplateAllocate " ,
" Allocates a new virtual machine template " ,
" A:ss " ,
true )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_tpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : TEMPLATE ;
2011-05-28 06:03:09 +04:00
} ;
~ TemplateAllocate ( ) { } ;
/* --------------------------------------------------------------------- */
Template * get_object_template ( )
{
return new VirtualMachineTemplate ;
} ;
int pool_allocate ( xmlrpc_c : : paramList const & _paramList ,
Template * tmpl ,
int & id ,
2011-07-07 14:45:13 +04:00
string & error_str ,
RequestAttributes & att ) ;
2011-05-28 06:03:09 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class HostAllocate : public RequestManagerAllocate
{
public :
HostAllocate ( ) :
2011-06-29 14:50:16 +04:00
RequestManagerAllocate ( " HostAllocate " ,
2011-05-28 06:03:09 +04:00
" Allocates a new host " ,
2011-12-13 20:35:17 +04:00
" A:ssssss " ,
2011-05-28 06:03:09 +04:00
false )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_hpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : HOST ;
2011-05-28 06:03:09 +04:00
} ;
~ HostAllocate ( ) { } ;
int pool_allocate ( xmlrpc_c : : paramList const & _paramList ,
Template * tmpl ,
int & id ,
2011-07-07 14:45:13 +04:00
string & error_str ,
RequestAttributes & att ) ;
2011-05-28 06:03:09 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class UserAllocate : public RequestManagerAllocate
{
public :
UserAllocate ( ) :
2011-06-29 14:50:16 +04:00
RequestManagerAllocate ( " UserAllocate " ,
2011-05-28 06:03:09 +04:00
" Returns user information " ,
2011-11-02 20:36:53 +04:00
" A:ssss " ,
2011-05-28 06:03:09 +04:00
false )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_upool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : USER ;
2011-05-28 06:03:09 +04:00
} ;
~ UserAllocate ( ) { } ;
int pool_allocate ( xmlrpc_c : : paramList const & _paramList ,
Template * tmpl ,
int & id ,
2011-07-07 14:45:13 +04:00
string & error_str ,
RequestAttributes & att ) ;
2011-05-28 06:03:09 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class GroupAllocate : public RequestManagerAllocate
{
public :
GroupAllocate ( ) :
2011-06-01 14:37:39 +04:00
RequestManagerAllocate ( " GroupAllocate " ,
2011-05-28 06:03:09 +04:00
" Allocates a new group " ,
" A:ss " ,
false )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_gpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : GROUP ;
2011-05-28 06:03:09 +04:00
} ;
~ GroupAllocate ( ) { } ;
int pool_allocate ( xmlrpc_c : : paramList const & _paramList ,
Template * tmpl ,
int & id ,
2011-07-07 14:45:13 +04:00
string & error_str ,
RequestAttributes & att ) ;
2011-05-28 06:03:09 +04:00
} ;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
# endif