2011-06-02 02:55:43 +04:00
/* -------------------------------------------------------------------------- */
2023-01-09 14:23:19 +03:00
/* Copyright 2002-2023, OpenNebula Project, OpenNebula Systems */
2011-06-02 02:55:43 +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_VM_TEMPLATE_H
# define REQUEST_MANAGER_VM_TEMPLATE_H
# include "Request.h"
# include "Nebula.h"
2019-12-10 13:45:15 +03:00
# include "VMTemplatePool.h"
2011-06-02 02:55:43 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class RequestManagerVMTemplate : public Request
{
protected :
2020-07-02 23:42:10 +03:00
RequestManagerVMTemplate ( const std : : string & method_name ,
const std : : string & help ,
const std : : string & params )
2011-06-02 02:55:43 +04:00
: Request ( method_name , params , help )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_tpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : TEMPLATE ;
2011-06-02 02:55:43 +04:00
} ;
~ RequestManagerVMTemplate ( ) { } ;
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class VMTemplateInstantiate : public RequestManagerVMTemplate
{
public :
VMTemplateInstantiate ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerVMTemplate ( " one.template.instantiate " , " Instantiates a new "
2016-04-21 17:08:28 +03:00
" virtual machine using a template " , " A:sisbs " )
2011-06-02 02:55:43 +04:00
{
2011-12-28 20:51:10 +04:00
auth_op = AuthRequest : : USE ;
2011-06-02 02:55:43 +04:00
} ;
~ VMTemplateInstantiate ( ) { } ;
2016-01-27 15:29:30 +03:00
/**
* Instantiates the VM Template , checking permissions , quotas , etc
* @ param id VM Template ID
* @ param name Name for the new VM . Can be empty
* @ param on_hold True to start the VM on HOLD state
2016-04-21 17:08:28 +03:00
* @ param s_uattr Template supplied by user to merge with the original
2016-01-27 15:29:30 +03:00
* contents . Can be empty
* @ param extra_attrs Template to be merged . It should contain internal
* configuration , and it won ' t be authenticated or checked for restricted
* attributes . Can be 0
2016-01-30 15:55:13 +03:00
* @ param vmid on success of the new VM
* @ param att the specific request attributes
2016-01-27 15:29:30 +03:00
*
2016-01-30 15:55:13 +03:00
* @ return ErroCode for the request .
2016-01-27 15:29:30 +03:00
*/
2023-01-31 15:46:09 +03:00
ErrorCode request_execute ( int id , const std : : string & name , bool on_hold ,
2020-07-02 23:42:10 +03:00
const std : : string & s_uattr , Template * extra_attrs , int & vid ,
2016-04-21 17:08:28 +03:00
RequestAttributes & att ) ;
/**
* Parse & merge user attributes ( check if the request user is not oneadmin )
* @ param tmpl to merge the attributes to
* @ param s_uattr Template supplied by user to merge with the original
* contents . Can be empty
* @ param att the specific request attributes
*/
2020-07-02 23:42:10 +03:00
ErrorCode merge ( Template * tmpl , const std : : string & s_uattr ,
RequestAttributes & att ) ;
2016-04-21 17:08:28 +03:00
protected :
void request_execute ( xmlrpc_c : : paramList const & _paramList ,
2019-07-05 18:23:21 +03:00
RequestAttributes & att ) override ;
2011-06-02 02:55:43 +04:00
} ;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
# endif