2011-05-29 02:37:59 +04:00
/* -------------------------------------------------------------------------- */
2014-01-09 14:51:20 +04:00
/* Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs */
2011-05-29 02:37:59 +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_VIRTUAL_NETWORK_H
# define REQUEST_MANAGER_VIRTUAL_NETWORK_H
# include "Request.h"
# include "Nebula.h"
using namespace std ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class RequestManagerVirtualNetwork : public Request
{
protected :
RequestManagerVirtualNetwork ( const string & method_name ,
const string & help )
: Request ( method_name , " A:sis " , help )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vnpool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : NET ;
2011-05-29 02:37:59 +04:00
auth_op = AuthRequest : : MANAGE ;
} ;
~ RequestManagerVirtualNetwork ( ) { } ;
/* -------------------------------------------------------------------- */
2011-07-07 14:45:13 +04:00
void request_execute ( xmlrpc_c : : paramList const & _paramList ,
RequestAttributes & att ) ;
2011-05-29 02:37:59 +04:00
virtual int leases_action ( VirtualNetwork * vn ,
VirtualNetworkTemplate * tmpl ,
2014-05-27 19:19:36 +04:00
RequestAttributes & att ,
2011-05-29 02:37:59 +04:00
string & error_str ) = 0 ;
/* -------------------------------------------------------------------- */
2012-01-30 22:31:21 +04:00
string leases_error ( const string & error ) ;
2011-05-29 02:37:59 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2014-05-22 22:20:33 +04:00
class VirtualNetworkAddAddressRange : public RequestManagerVirtualNetwork
2011-05-29 02:37:59 +04:00
{
public :
2014-05-22 22:20:33 +04:00
VirtualNetworkAddAddressRange ( ) :
RequestManagerVirtualNetwork ( " VirtualNetworkAddAddressRange " ,
2014-05-30 18:22:26 +04:00
" Adds address ranges to a virtual network " )
{
auth_op = AuthRequest : : ADMIN ;
} ;
2014-05-22 22:20:33 +04:00
~ VirtualNetworkAddAddressRange ( ) { } ;
2011-05-29 02:37:59 +04:00
int leases_action ( VirtualNetwork * vn ,
VirtualNetworkTemplate * tmpl ,
2014-05-27 19:19:36 +04:00
RequestAttributes & att ,
2011-05-29 02:37:59 +04:00
string & error_str )
{
2014-05-22 22:20:33 +04:00
return vn - > add_ar ( tmpl , error_str ) ;
2011-05-29 02:37:59 +04:00
}
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2014-05-22 22:20:33 +04:00
class VirtualNetworkRmAddressRange : public Request
2011-05-29 02:37:59 +04:00
{
public :
2014-06-02 03:39:22 +04:00
VirtualNetworkRmAddressRange (
const string & name = " VirtualNetworkRmAddressRange " ,
const string & sign = " A:sii " ,
const string & help = " Removes an address range from a virtual network " )
: Request ( name , sign , help )
2011-05-29 02:37:59 +04:00
{
2014-05-22 22:20:33 +04:00
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vnpool ( ) ;
auth_object = PoolObjectSQL : : NET ;
2014-05-30 18:22:26 +04:00
auth_op = AuthRequest : : ADMIN ;
2014-05-22 22:20:33 +04:00
} ;
2014-06-02 03:39:22 +04:00
virtual ~ VirtualNetworkRmAddressRange ( ) { } ;
2014-05-22 22:20:33 +04:00
void request_execute ( xmlrpc_c : : paramList const & _paramList ,
RequestAttributes & att ) ;
2011-05-29 02:37:59 +04:00
} ;
2011-11-29 19:12:00 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2014-06-02 03:39:22 +04:00
class VirtualNetworkFreeAddressRange : public VirtualNetworkRmAddressRange
{
public :
VirtualNetworkFreeAddressRange ( ) : VirtualNetworkRmAddressRange (
" VirtualNetworkFreeAddressRange " ,
" A:sii " ,
" Frees a reserved address range from a virtual network " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vnpool ( ) ;
auth_object = PoolObjectSQL : : NET ;
auth_op = AuthRequest : : MANAGE ;
} ;
~ VirtualNetworkFreeAddressRange ( ) { } ;
void request_execute ( xmlrpc_c : : paramList const & _paramList ,
RequestAttributes & att )
{
VirtualNetworkRmAddressRange : : request_execute ( _paramList , att ) ;
}
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2014-05-23 02:24:14 +04:00
class VirtualNetworkUpdateAddressRange : public RequestManagerVirtualNetwork
{
public :
VirtualNetworkUpdateAddressRange ( ) :
RequestManagerVirtualNetwork ( " VirtualNetworkUpdateAddressRange " ,
2014-05-30 18:22:26 +04:00
" Updates address ranges to a virtual network " )
{
2014-09-04 15:38:11 +04:00
auth_op = AuthRequest : : MANAGE ;
2014-05-30 18:22:26 +04:00
} ;
2014-05-23 02:24:14 +04:00
~ VirtualNetworkUpdateAddressRange ( ) { } ;
int leases_action ( VirtualNetwork * vn ,
VirtualNetworkTemplate * tmpl ,
2014-05-27 19:19:36 +04:00
RequestAttributes & att ,
2014-05-23 02:24:14 +04:00
string & error_str )
{
2014-09-04 15:38:11 +04:00
if ( att . uid ! = UserPool : : ONEADMIN_ID & & att . gid ! = GroupPool : : ONEADMIN_ID )
{
return vn - > update_ar ( tmpl , true , error_str ) ;
}
else
{
return vn - > update_ar ( tmpl , false , error_str ) ;
}
2014-05-23 02:24:14 +04:00
} ;
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2011-11-29 19:12:00 +04:00
class VirtualNetworkHold : public RequestManagerVirtualNetwork
{
public :
VirtualNetworkHold ( ) :
RequestManagerVirtualNetwork ( " VirtualNetworkHold " ,
" Holds a virtual network Lease as used " ) { } ;
~ VirtualNetworkHold ( ) { } ;
int leases_action ( VirtualNetwork * vn ,
VirtualNetworkTemplate * tmpl ,
2014-05-27 19:19:36 +04:00
RequestAttributes & att ,
2011-11-29 19:12:00 +04:00
string & error_str )
{
return vn - > hold_leases ( tmpl , error_str ) ;
}
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class VirtualNetworkRelease : public RequestManagerVirtualNetwork
{
public :
VirtualNetworkRelease ( ) :
RequestManagerVirtualNetwork ( " VirtualNetworkRelease " ,
" Releases a virtual network Lease on hold " ) { } ;
~ VirtualNetworkRelease ( ) { } ;
int leases_action ( VirtualNetwork * vn ,
VirtualNetworkTemplate * tmpl ,
2014-05-27 19:19:36 +04:00
RequestAttributes & att ,
2011-11-29 19:12:00 +04:00
string & error_str )
{
return vn - > free_leases ( tmpl , error_str ) ;
}
} ;
2014-05-27 19:19:36 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class VirtualNetworkReserve : public Request
{
public :
VirtualNetworkReserve ( ) : Request ( " VirtualNetworkReserve " , " A:sis " ,
" Reserve network addresses " )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_vnpool ( ) ;
auth_object = PoolObjectSQL : : NET ;
auth_op = AuthRequest : : USE ;
} ;
~ VirtualNetworkReserve ( ) { } ;
void request_execute ( xmlrpc_c : : paramList const & _paramList ,
RequestAttributes & att ) ;
} ;
2011-05-29 02:37:59 +04:00
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
# endif