2008-06-17 20:27:32 +04:00
/* -------------------------------------------------------------------------- */
2016-05-04 13:33:23 +03:00
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems */
2008-06-17 20:27:32 +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 NEBULA_H_
# define NEBULA_H_
2017-04-21 17:52:54 +03:00
# include "LogDB.h"
2012-11-30 05:59:26 +04:00
# include "SystemDB.h"
2008-06-17 20:27:32 +04:00
# include "NebulaTemplate.h"
# include "VirtualMachinePool.h"
2008-11-13 19:21:17 +03:00
# include "VirtualNetworkPool.h"
2008-06-17 20:27:32 +04:00
# include "HostPool.h"
2009-07-09 18:34:34 +04:00
# include "UserPool.h"
2011-03-30 21:03:49 +04:00
# include "VMTemplatePool.h"
2011-05-10 20:45:15 +04:00
# include "GroupPool.h"
2012-02-09 20:56:47 +04:00
# include "DatastorePool.h"
2012-02-24 18:53:53 +04:00
# include "ClusterPool.h"
2012-06-08 17:41:59 +04:00
# include "DocumentPool.h"
2013-12-12 22:08:59 +04:00
# include "ZonePool.h"
2014-09-08 13:50:25 +04:00
# include "SecurityGroupPool.h"
2014-12-19 19:30:00 +03:00
# include "VdcPool.h"
2015-11-30 18:50:23 +03:00
# include "VirtualRouterPool.h"
2015-12-06 01:52:28 +03:00
# include "MarketPlacePool.h"
2015-12-11 17:53:19 +03:00
# include "MarketPlaceAppPool.h"
2017-01-03 03:22:10 +03:00
# include "VMGroupPool.h"
2008-06-17 20:27:32 +04:00
# include "VirtualMachineManager.h"
# include "LifeCycleManager.h"
# include "InformationManager.h"
# include "TransferManager.h"
# include "DispatchManager.h"
# include "RequestManager.h"
2009-04-04 03:34:33 +04:00
# include "HookManager.h"
2010-07-08 21:28:10 +04:00
# include "AuthManager.h"
2011-06-22 21:22:52 +04:00
# include "AclManager.h"
2011-03-22 20:21:09 +03:00
# include "ImageManager.h"
2015-12-14 18:47:33 +03:00
# include "MarketPlaceManager.h"
2016-08-18 22:42:24 +03:00
# include "IPAMManager.h"
2017-04-25 18:15:31 +03:00
# include "RaftManager.h"
2008-06-17 20:27:32 +04:00
2012-11-26 15:48:10 +04:00
# include "DefaultQuotas.h"
2012-11-19 18:19:09 +04:00
2011-04-29 20:59:39 +04:00
# include "Callbackable.h"
2012-11-30 05:59:26 +04:00
/**
* This is the main class for the OpenNebula daemon oned . It stores references
* to the main modules and data pools . It also includes functions to bootstrap
* the system and start all its components .
*/
class Nebula
2008-06-17 20:27:32 +04:00
{
public :
2010-04-11 00:19:49 +04:00
static Nebula & instance ( )
2008-06-17 20:27:32 +04:00
{
static Nebula nebulad ;
2010-04-11 00:19:49 +04:00
2008-06-17 20:27:32 +04:00
return nebulad ;
} ;
2010-04-11 00:19:49 +04:00
2008-06-17 20:27:32 +04:00
// --------------------------------------------------------------
// Pool Accessors
2010-04-11 00:19:49 +04:00
// --------------------------------------------------------------
2017-04-21 17:52:54 +03:00
LogDB * get_logdb ( )
{
return logdb ;
} ;
2010-04-11 00:19:49 +04:00
2008-06-17 20:27:32 +04:00
VirtualMachinePool * get_vmpool ( )
{
return vmpool ;
2010-04-11 00:19:49 +04:00
} ;
2008-06-17 20:27:32 +04:00
HostPool * get_hpool ( )
{
return hpool ;
2010-04-11 00:19:49 +04:00
} ;
2008-11-13 19:21:17 +03:00
VirtualNetworkPool * get_vnpool ( )
{
return vnpool ;
} ;
2010-04-11 00:19:49 +04:00
2009-07-09 18:34:34 +04:00
UserPool * get_upool ( )
{
return upool ;
} ;
2008-06-17 20:27:32 +04:00
2010-06-25 15:24:54 +04:00
ImagePool * get_ipool ( )
{
return ipool ;
} ;
2011-05-10 20:45:15 +04:00
GroupPool * get_gpool ( )
{
return gpool ;
} ;
2011-03-30 21:03:49 +04:00
VMTemplatePool * get_tpool ( )
{
return tpool ;
} ;
2012-02-09 20:56:47 +04:00
DatastorePool * get_dspool ( )
{
return dspool ;
} ;
2012-02-24 18:53:53 +04:00
ClusterPool * get_clpool ( )
{
return clpool ;
} ;
2012-06-08 17:41:59 +04:00
DocumentPool * get_docpool ( )
{
return docpool ;
} ;
2013-12-12 22:08:59 +04:00
ZonePool * get_zonepool ( )
{
return zonepool ;
} ;
2014-09-08 13:50:25 +04:00
SecurityGroupPool * get_secgrouppool ( )
{
return secgrouppool ;
} ;
2014-12-19 19:30:00 +03:00
VdcPool * get_vdcpool ( )
{
return vdcpool ;
} ;
2015-11-30 18:50:23 +03:00
VirtualRouterPool * get_vrouterpool ( )
{
return vrouterpool ;
} ;
2015-12-11 17:53:19 +03:00
MarketPlacePool * get_marketpool ( )
2015-12-06 01:52:28 +03:00
{
2015-12-11 17:53:19 +03:00
return marketpool ;
2015-12-06 01:52:28 +03:00
} ;
2015-12-11 17:53:19 +03:00
MarketPlaceAppPool * get_apppool ( )
{
return apppool ;
} ;
2017-01-03 03:22:10 +03:00
VMGroupPool * get_vmgrouppool ( )
{
return vmgrouppool ;
} ;
2008-06-17 20:27:32 +04:00
// --------------------------------------------------------------
// Manager Accessors
2010-04-11 00:19:49 +04:00
// --------------------------------------------------------------
2008-06-17 20:27:32 +04:00
VirtualMachineManager * get_vmm ( )
{
return vmm ;
} ;
LifeCycleManager * get_lcm ( )
{
return lcm ;
} ;
2010-04-11 00:19:49 +04:00
2015-07-01 22:15:40 +03:00
InformationManager * get_im ( )
2008-06-17 20:27:32 +04:00
{
return im ;
} ;
TransferManager * get_tm ( )
{
return tm ;
} ;
DispatchManager * get_dm ( )
{
return dm ;
} ;
2010-04-11 00:19:49 +04:00
2009-04-04 03:34:33 +04:00
HookManager * get_hm ( )
{
return hm ;
} ;
2010-04-11 00:19:49 +04:00
2010-07-08 21:28:10 +04:00
AuthManager * get_authm ( )
{
return authm ;
} ;
2011-03-22 20:21:09 +03:00
ImageManager * get_imagem ( )
{
return imagem ;
} ;
2011-06-22 21:22:52 +04:00
AclManager * get_aclm ( )
{
return aclm ;
} ;
2015-12-14 18:47:33 +03:00
MarketPlaceManager * get_marketm ( )
{
return marketm ;
} ;
2016-08-18 22:42:24 +03:00
IPAMManager * get_ipamm ( )
{
return ipamm ;
} ;
2017-04-25 18:15:31 +03:00
RaftManager * get_raftm ( )
{
return raftm ;
} ;
2008-06-17 20:27:32 +04:00
// --------------------------------------------------------------
// Environment & Configuration
2009-01-02 17:58:51 +03:00
// --------------------------------------------------------------
2010-04-11 00:19:49 +04:00
2012-04-03 20:02:14 +04:00
/**
2013-01-31 23:43:17 +04:00
* Returns the value of LOG - > DEBUG_LEVEL in oned . conf file
2012-04-03 20:02:14 +04:00
* @ return the debug level , to instantiate Log ' ers
*/
2016-01-04 13:29:20 +03:00
Log : : MessageType get_debug_level ( ) const ;
2012-04-03 20:02:14 +04:00
2013-01-31 23:43:17 +04:00
/**
* Returns the value of LOG - > SYSTEM in oned . conf file
2013-02-01 21:49:03 +04:00
* @ return the logging system CERR , FILE_TS or SYSLOG
2013-01-31 23:43:17 +04:00
*/
2016-01-04 13:29:20 +03:00
NebulaLog : : LogType get_log_system ( ) const ;
2013-01-31 23:43:17 +04:00
2009-01-02 17:58:51 +03:00
/**
2010-04-11 00:19:49 +04:00
* Returns the value of ONE_LOCATION env variable . When this variable is
2009-01-02 17:58:51 +03:00
* not defined the nebula location is " / " .
2015-07-01 22:15:40 +03:00
* @ return the nebula location .
2010-04-11 00:19:49 +04:00
*/
2008-11-13 19:21:17 +03:00
const string & get_nebula_location ( )
2008-06-17 20:27:32 +04:00
{
return nebula_location ;
} ;
2009-01-02 17:58:51 +03:00
/**
2010-04-11 00:19:49 +04:00
* Returns the path where mad executables are stored , if ONE_LOCATION is
* defined this path points to $ ONE_LOCATION / bin , otherwise it is
2009-01-02 17:58:51 +03:00
* / usr / lib / one / mads .
2015-07-01 22:15:40 +03:00
* @ return the mad execs location .
2009-01-02 17:58:51 +03:00
*/
const string & get_mad_location ( )
{
2015-07-01 22:15:40 +03:00
return mad_location ;
2009-01-02 17:58:51 +03:00
} ;
/**
2010-04-11 00:19:49 +04:00
* Returns the path where defaults for mads are stored , if ONE_LOCATION is
2009-01-02 17:58:51 +03:00
* defined this path points to $ ONE_LOCATION / etc , otherwise it is / etc / one
2015-07-01 22:15:40 +03:00
* @ return the mad defaults location .
2009-01-02 17:58:51 +03:00
*/
const string & get_defaults_location ( )
{
2015-07-01 22:15:40 +03:00
return etc_location ;
2009-01-02 17:58:51 +03:00
} ;
2010-04-11 00:19:49 +04:00
2009-01-02 17:58:51 +03:00
/**
* Returns the path where logs ( oned . log , schedd . log , . . . ) are generated
2010-04-11 00:19:49 +04:00
* if ONE_LOCATION is defined this path points to $ ONE_LOCATION / var ,
2009-01-02 17:58:51 +03:00
* otherwise it is / var / log / one .
2015-07-01 22:15:40 +03:00
* @ return the log location .
2009-01-02 17:58:51 +03:00
*/
const string & get_log_location ( )
{
2015-07-01 22:15:40 +03:00
return log_location ;
2009-01-02 17:58:51 +03:00
} ;
/**
2012-02-25 02:13:22 +04:00
* Returns the default var location . When ONE_LOCATION is defined this path
* points to $ ONE_LOCATION / var , otherwise it is / var / lib / one .
2015-07-01 22:15:40 +03:00
* @ return the log location .
2009-01-02 17:58:51 +03:00
*/
const string & get_var_location ( )
{
2015-07-01 22:15:40 +03:00
return var_location ;
2009-01-02 17:58:51 +03:00
} ;
2010-04-11 00:19:49 +04:00
2013-10-20 17:11:13 +04:00
/**
*
*
*/
2016-03-16 15:07:10 +03:00
void get_ds_location ( string & dsloc ) ;
2013-10-20 17:11:13 +04:00
2012-10-28 22:19:57 +04:00
/**
* Returns the default vms location . When ONE_LOCATION is defined this path
* points to $ ONE_LOCATION / var / vms , otherwise it is / var / lib / one / vms . This
* location stores vm related files : deployment , transfer , context , and
* logs ( in self - contained mode only )
* @ return the vms location .
*/
const string & get_vms_location ( )
{
return vms_location ;
} ;
2009-01-02 17:58:51 +03:00
/**
* Returns the path of the log file for a VM , depending where OpenNebula is
* installed ,
* $ ONE_LOCATION / var / $ VM_ID / vm . log
* or
* / var / log / one / $ VM_ID . log
* @ return the log location for the VM .
*/
2016-01-04 13:29:20 +03:00
string get_vm_log_filename ( int oid ) ;
2010-04-11 00:19:49 +04:00
2012-12-24 05:41:17 +04:00
/**
* Returns the name of the host running oned
* @ return the name
*/
2008-11-13 19:21:17 +03:00
const string & get_nebula_hostname ( )
{
return hostname ;
} ;
2010-04-11 00:19:49 +04:00
2012-12-24 05:41:17 +04:00
/**
* Returns the version of oned
* @ return the version
*/
2008-06-17 20:27:32 +04:00
static string version ( )
{
2014-03-04 15:49:42 +04:00
return " OpenNebula " + code_version ( ) ;
2008-06-17 20:27:32 +04:00
} ;
2010-04-11 00:19:49 +04:00
2014-02-21 21:08:41 +04:00
/**
* Returns the version of oned
* @ return
*/
static string code_version ( )
{
2016-09-27 12:49:32 +03:00
return " 5.2.0 " ; // bump version
2014-02-21 21:08:41 +04:00
}
/**
2014-02-23 22:31:08 +04:00
* Version needed for the DB , shared tables
2014-02-21 21:08:41 +04:00
* @ return
*/
2014-02-23 22:31:08 +04:00
static string shared_db_version ( )
2011-04-29 20:59:39 +04:00
{
2016-10-06 16:17:40 +03:00
return " 5.2.0 " ;
2011-07-12 15:54:53 +04:00
}
2011-04-29 20:59:39 +04:00
2014-02-21 21:08:41 +04:00
/**
* Version needed for the DB , local tables
* @ return
*/
2014-02-23 22:31:08 +04:00
static string local_db_version ( )
2014-02-21 21:08:41 +04:00
{
2016-11-25 15:53:05 +03:00
return " 5.3.80 " ;
2014-02-21 21:08:41 +04:00
}
2012-12-24 05:41:17 +04:00
/**
* Starts all the modules and services for OpenNebula
*/
2013-10-08 17:09:30 +04:00
void start ( bool bootstrap_only = false ) ;
2010-04-11 00:19:49 +04:00
2013-10-05 23:34:55 +04:00
/**
* Initialize the database
*/
2016-01-04 13:29:20 +03:00
void bootstrap_db ( )
{
start ( true ) ;
}
2013-10-05 23:34:55 +04:00
2014-01-22 15:55:30 +04:00
// --------------------------------------------------------------
// Federation
// --------------------------------------------------------------
bool is_federation_enabled ( )
{
return federation_enabled ;
} ;
bool is_federation_master ( )
{
return federation_master ;
} ;
2014-01-22 21:54:48 +04:00
bool is_federation_slave ( )
{
return federation_enabled & & ! federation_master ;
} ;
2014-01-22 15:55:30 +04:00
int get_zone_id ( )
{
return zone_id ;
} ;
2017-04-21 17:52:54 +03:00
int get_server_id ( )
{
return server_id ;
} ;
2014-01-22 15:55:30 +04:00
const string & get_master_oned ( )
{
return master_oned ;
} ;
2012-12-24 05:41:17 +04:00
// -----------------------------------------------------------------------
// Configuration attributes (read from oned.conf)
// -----------------------------------------------------------------------
/**
* Gets a configuration attribute for oned
* @ param name of the attribute
* @ param value of the attribute
*/
2016-02-04 15:10:42 +03:00
template < typename T >
void get_configuration_attribute ( const string & name , T & value ) const
2014-08-11 19:22:15 +04:00
{
nebula_configuration - > get ( name , value ) ;
} ;
2017-03-13 01:39:45 +03:00
/**
* Gets a user - configurable attribute for oned . Users ( and groups ) may
* store oned attributes in the " OPENNEBULA " vector . This function gets
* the value querying first the user , then the group and finally oned . conf
2017-03-21 14:23:02 +03:00
* @ param uid of the user , if - 1 the user template is not considered
2017-03-13 01:39:45 +03:00
* @ param gid of the group
* @ param name of the attribute
* @ param value of the attribute
*
* @ return 0 on success - 1 otherwise
*/
template < typename T >
int get_configuration_attribute ( int uid , int gid , const std : : string & name ,
T & value ) const
{
2017-03-21 14:23:02 +03:00
if ( uid ! = - 1 )
2017-03-13 01:39:45 +03:00
{
2017-03-21 14:23:02 +03:00
User * user = upool - > get ( uid , true ) ;
if ( user = = 0 )
{
return - 1 ;
}
2017-03-13 01:39:45 +03:00
2017-03-21 14:23:02 +03:00
const VectorAttribute * uconf ;
2017-03-13 01:39:45 +03:00
2017-03-21 14:23:02 +03:00
uconf = user - > get_template_attribute ( " OPENNEBULA " ) ;
2017-03-13 01:39:45 +03:00
2017-03-21 14:23:02 +03:00
if ( uconf ! = 0 )
2017-03-13 01:39:45 +03:00
{
2017-03-21 14:23:02 +03:00
if ( uconf - > vector_value ( name , value ) = = 0 )
{
user - > unlock ( ) ;
return 0 ;
}
2017-03-13 01:39:45 +03:00
}
2017-03-21 14:23:02 +03:00
user - > unlock ( ) ;
}
2017-03-13 01:39:45 +03:00
Group * group = gpool - > get ( gid , true ) ;
if ( group = = 0 )
{
return - 1 ;
}
const VectorAttribute * gconf ;
gconf = group - > get_template_attribute ( " OPENNEBULA " ) ;
if ( gconf ! = 0 )
{
if ( gconf - > vector_value ( name , value ) = = 0 )
{
group - > unlock ( ) ;
return 0 ;
}
}
group - > unlock ( ) ;
nebula_configuration - > get ( name , value ) ;
return 0 ;
}
2015-12-21 21:27:26 +03:00
/**
* Gets a DS configuration attribute
*/
2016-08-31 15:52:33 +03:00
int get_ds_conf_attribute ( const std : : string & ds_name ,
2016-02-09 18:33:13 +03:00
const VectorAttribute * & value ) const
{
return get_conf_attribute ( " DS_MAD_CONF " , ds_name , value ) ;
} ;
2015-12-21 21:27:26 +03:00
2013-10-23 18:15:18 +04:00
/**
* Gets a TM configuration attribute
*/
2016-08-31 15:52:33 +03:00
int get_tm_conf_attribute ( const string & tm_name ,
2016-02-09 18:33:13 +03:00
const VectorAttribute * & value ) const
{
return get_conf_attribute ( " TM_MAD_CONF " , tm_name , value ) ;
} ;
2013-10-23 18:15:18 +04:00
2016-02-03 18:03:22 +03:00
/**
* Gets a Market configuration attribute
*/
2016-08-31 15:52:33 +03:00
int get_market_conf_attribute ( const string & mk_name ,
2016-02-09 18:33:13 +03:00
const VectorAttribute * & value ) const
{
return get_conf_attribute ( " MARKET_MAD_CONF " , mk_name , value ) ;
} ;
2016-02-03 18:03:22 +03:00
2016-06-29 18:17:18 +03:00
/**
* Gets an Auth driver configuration attribute
*/
2016-08-31 15:52:33 +03:00
template < typename T >
int get_auth_conf_attribute ( const string & driver , const string & attribute ,
T & value ) const
2016-06-29 18:17:18 +03:00
{
2016-08-31 15:52:33 +03:00
return get_conf_attribute ( " AUTH_MAD_CONF " , driver , attribute , value ) ;
2016-06-29 18:17:18 +03:00
} ;
2017-01-30 15:19:32 +03:00
/**
* Return the Authorization operation for a VM action
*
*/
AuthRequest : : Operation get_vm_auth_op ( History : : VMAction action )
{
return nebula_configuration - > get_vm_auth_op ( action ) ;
}
2012-12-24 05:41:17 +04:00
/**
* Gets an XML document with all of the configuration attributes
* @ return the XML
*/
2012-11-14 15:54:31 +04:00
string get_configuration_xml ( ) const
{
string xml ;
return nebula_configuration - > to_xml ( xml ) ;
} ;
2012-12-24 05:41:17 +04:00
// -----------------------------------------------------------------------
// Default Quotas
// -----------------------------------------------------------------------
/**
* Get the default quotas for OpenNebula users
* @ return the default quotas
*/
2012-11-26 19:12:05 +04:00
const DefaultQuotas & get_default_user_quota ( )
2012-11-19 18:19:09 +04:00
{
return default_user_quota ;
} ;
2012-12-24 05:41:17 +04:00
/**
* Set the default quotas for OpenNebula users
* @ param tmpl template with the default quotas
* @ param error describes the error if any
*
* @ return 0 if success
*/
2012-11-23 19:03:10 +04:00
int set_default_user_quota ( Template * tmpl , string & error )
{
2012-12-24 05:41:17 +04:00
int rc = default_user_quota . set ( tmpl , error ) ;
2012-11-26 21:14:12 +04:00
if ( rc = = 0 )
{
2012-11-30 05:59:26 +04:00
rc = default_user_quota . update ( ) ;
2012-11-26 21:14:12 +04:00
}
return rc ;
2012-11-23 19:03:10 +04:00
} ;
2012-12-24 05:41:17 +04:00
/**
* Get the default quotas for OpenNebula for groups
* @ return the default quotas
*/
2012-11-26 19:12:05 +04:00
const DefaultQuotas & get_default_group_quota ( )
2012-11-19 19:38:39 +04:00
{
return default_group_quota ;
} ;
2012-12-24 05:41:17 +04:00
/**
* Set the default quotas for OpenNebula groups
* @ param tmpl template with the default quotas
* @ param error describes the error if any
*
* @ return 0 if success
*/
2012-11-23 19:03:10 +04:00
int set_default_group_quota ( Template * tmpl , string & error )
{
2012-12-24 05:41:17 +04:00
int rc = default_group_quota . set ( tmpl , error ) ;
2012-11-26 21:14:12 +04:00
if ( rc = = 0 )
{
2012-11-30 05:59:26 +04:00
rc = default_group_quota . update ( ) ;
2012-11-26 21:14:12 +04:00
}
return rc ;
2012-11-23 19:03:10 +04:00
} ;
2012-11-30 05:59:26 +04:00
// -----------------------------------------------------------------------
// System attributes
// -----------------------------------------------------------------------
/**
* Reads a System attribute from the DB
* @ param attr_name name of the attribute
* @ param cb Callback that will receive the attribute in XML
* @ return 0 on success
*/
int select_sys_attribute ( const string & attr_name , string & attr_xml )
{
return system_db - > select_sys_attribute ( attr_name , attr_xml ) ;
} ;
/**
* Writes a system attribute in the database .
* @ param db pointer to the db
* @ return 0 on success
*/
int insert_sys_attribute (
const string & attr_name ,
const string & xml_attr ,
string & error_str )
{
return system_db - > insert_sys_attribute ( attr_name , xml_attr , error_str ) ;
} ;
/**
* Updates the system attribute in the database .
* @ param db pointer to the db
* @ return 0 on success
*/
int update_sys_attribute (
const string & attr_name ,
const string & xml_attr ,
string & error_str )
{
return system_db - > update_sys_attribute ( attr_name , xml_attr , error_str ) ;
} ;
2008-06-17 20:27:32 +04:00
private :
2010-04-11 00:19:49 +04:00
// -----------------------------------------------------------------------
2008-06-17 20:27:32 +04:00
//Constructors and = are private to only access the class through instance
// -----------------------------------------------------------------------
2010-04-11 00:19:49 +04:00
2012-11-19 18:19:09 +04:00
Nebula ( ) : nebula_configuration ( 0 ) ,
2012-11-26 19:12:05 +04:00
default_user_quota ( " DEFAULT_USER_QUOTAS " ,
" /DEFAULT_USER_QUOTAS/DATASTORE_QUOTA " ,
" /DEFAULT_USER_QUOTAS/NETWORK_QUOTA " ,
" /DEFAULT_USER_QUOTAS/IMAGE_QUOTA " ,
" /DEFAULT_USER_QUOTAS/VM_QUOTA " ) ,
default_group_quota ( " DEFAULT_GROUP_QUOTAS " ,
" /DEFAULT_GROUP_QUOTAS/DATASTORE_QUOTA " ,
" /DEFAULT_GROUP_QUOTAS/NETWORK_QUOTA " ,
" /DEFAULT_GROUP_QUOTAS/IMAGE_QUOTA " ,
" /DEFAULT_GROUP_QUOTAS/VM_QUOTA " ) ,
2017-04-21 17:52:54 +03:00
system_db ( 0 ) , logdb ( 0 ) ,
2013-12-12 22:08:59 +04:00
vmpool ( 0 ) , hpool ( 0 ) , vnpool ( 0 ) , upool ( 0 ) , ipool ( 0 ) , gpool ( 0 ) , tpool ( 0 ) ,
2017-01-03 03:22:10 +03:00
dspool ( 0 ) , clpool ( 0 ) , docpool ( 0 ) , zonepool ( 0 ) , secgrouppool ( 0 ) ,
vdcpool ( 0 ) , vrouterpool ( 0 ) , marketpool ( 0 ) , apppool ( 0 ) , vmgrouppool ( 0 ) ,
lcm ( 0 ) , vmm ( 0 ) , im ( 0 ) , tm ( 0 ) , dm ( 0 ) , rm ( 0 ) , hm ( 0 ) , authm ( 0 ) , aclm ( 0 ) ,
2017-04-25 18:15:31 +03:00
imagem ( 0 ) , marketm ( 0 ) , ipamm ( 0 ) , raftm ( 0 )
2009-01-02 17:58:51 +03:00
{
2010-06-25 15:24:54 +04:00
const char * nl = getenv ( " ONE_LOCATION " ) ;
2009-01-02 17:58:51 +03:00
if ( nl = = 0 ) //OpenNebula installed under root directory
{
2010-06-25 15:24:54 +04:00
nebula_location = " / " ;
2010-04-11 00:19:49 +04:00
2010-08-17 02:28:48 +04:00
mad_location = " /usr/lib/one/mads/ " ;
etc_location = " /etc/one/ " ;
log_location = " /var/log/one/ " ;
var_location = " /var/lib/one/ " ;
2010-11-16 14:29:14 +03:00
remotes_location = " /var/lib/one/remotes/ " ;
2012-10-28 22:19:57 +04:00
vms_location = " /var/lib/one/vms/ " ;
2009-01-02 17:58:51 +03:00
}
else
{
2010-06-25 15:24:54 +04:00
nebula_location = nl ;
2010-04-11 00:19:49 +04:00
2010-06-25 15:24:54 +04:00
if ( nebula_location . at ( nebula_location . size ( ) - 1 ) ! = ' / ' )
{
nebula_location + = " / " ;
}
2010-04-11 00:19:49 +04:00
2010-08-17 02:28:48 +04:00
mad_location = nebula_location + " lib/mads/ " ;
etc_location = nebula_location + " etc/ " ;
log_location = nebula_location + " var/ " ;
var_location = nebula_location + " var/ " ;
2010-11-16 14:29:14 +03:00
remotes_location = nebula_location + " var/remotes/ " ;
2012-10-28 22:19:57 +04:00
vms_location = nebula_location + " var/vms/ " ;
2010-04-11 00:19:49 +04:00
}
2009-01-02 17:58:51 +03:00
} ;
2010-04-11 00:19:49 +04:00
2008-06-17 20:27:32 +04:00
~ Nebula ( )
{
2013-12-10 21:03:03 +04:00
delete vmpool ;
delete vnpool ;
delete hpool ;
delete upool ;
delete ipool ;
delete gpool ;
delete tpool ;
delete dspool ;
delete clpool ;
delete docpool ;
2013-12-12 22:08:59 +04:00
delete zonepool ;
2014-09-08 13:50:25 +04:00
delete secgrouppool ;
2014-12-19 19:30:00 +03:00
delete vdcpool ;
2015-11-30 18:50:23 +03:00
delete vrouterpool ;
2015-12-11 17:53:19 +03:00
delete marketpool ;
delete apppool ;
2017-01-03 03:22:10 +03:00
delete vmgrouppool ;
2013-12-10 21:03:03 +04:00
delete vmm ;
delete lcm ;
delete im ;
delete tm ;
delete dm ;
delete rm ;
delete hm ;
delete authm ;
delete aclm ;
delete imagem ;
2015-12-14 18:47:33 +03:00
delete marketm ;
2016-08-18 22:42:24 +03:00
delete ipamm ;
2017-04-25 18:15:31 +03:00
delete raftm ;
2013-12-10 21:03:03 +04:00
delete nebula_configuration ;
2017-04-21 17:52:54 +03:00
delete logdb ;
2013-12-10 21:03:03 +04:00
delete system_db ;
2008-06-17 20:27:32 +04:00
} ;
2010-04-11 00:19:49 +04:00
Nebula & operator = ( Nebula const & ) { return * this ; } ;
2008-06-17 20:27:32 +04:00
// ---------------------------------------------------------------
// Environment variables
// ---------------------------------------------------------------
2010-04-11 00:19:49 +04:00
2009-01-02 17:58:51 +03:00
string nebula_location ;
2010-04-11 00:19:49 +04:00
2015-07-01 22:15:40 +03:00
string mad_location ;
string etc_location ;
string log_location ;
string var_location ;
2010-08-02 13:24:01 +04:00
string hook_location ;
2010-08-17 02:28:48 +04:00
string remotes_location ;
2012-10-28 22:19:57 +04:00
string vms_location ;
2010-08-17 02:28:48 +04:00
2015-07-01 22:15:40 +03:00
string hostname ;
2010-04-11 00:19:49 +04:00
2008-06-17 20:27:32 +04:00
// ---------------------------------------------------------------
// Configuration
// ---------------------------------------------------------------
2012-11-30 05:59:26 +04:00
OpenNebulaTemplate * nebula_configuration ;
2010-04-11 00:19:49 +04:00
2014-01-22 15:55:30 +04:00
// ---------------------------------------------------------------
2017-04-30 00:25:53 +03:00
// Federation - HA
2014-01-22 15:55:30 +04:00
// ---------------------------------------------------------------
bool federation_enabled ;
bool federation_master ;
int zone_id ;
2017-04-21 17:52:54 +03:00
int server_id ;
2014-01-22 15:55:30 +04:00
string master_oned ;
2012-11-19 18:19:09 +04:00
// ---------------------------------------------------------------
// Default quotas
// ---------------------------------------------------------------
2012-11-26 15:48:10 +04:00
DefaultQuotas default_user_quota ;
DefaultQuotas default_group_quota ;
2012-11-19 18:19:09 +04:00
2012-11-30 05:59:26 +04:00
// ---------------------------------------------------------------
// The system database
// ---------------------------------------------------------------
SystemDB * system_db ;
2012-11-19 18:19:09 +04:00
2008-06-17 20:27:32 +04:00
// ---------------------------------------------------------------
// Nebula Pools
// ---------------------------------------------------------------
2010-04-11 00:19:49 +04:00
2017-04-21 17:52:54 +03:00
LogDB * logdb ;
2008-06-17 20:27:32 +04:00
VirtualMachinePool * vmpool ;
2008-11-13 19:21:17 +03:00
HostPool * hpool ;
VirtualNetworkPool * vnpool ;
2009-07-09 18:34:34 +04:00
UserPool * upool ;
2010-06-01 20:00:44 +04:00
ImagePool * ipool ;
2011-05-10 20:45:15 +04:00
GroupPool * gpool ;
2011-03-30 21:03:49 +04:00
VMTemplatePool * tpool ;
2012-02-09 20:56:47 +04:00
DatastorePool * dspool ;
2012-02-24 18:53:53 +04:00
ClusterPool * clpool ;
2012-06-08 17:41:59 +04:00
DocumentPool * docpool ;
2013-12-12 22:08:59 +04:00
ZonePool * zonepool ;
2014-09-08 13:50:25 +04:00
SecurityGroupPool * secgrouppool ;
2014-12-19 19:30:00 +03:00
VdcPool * vdcpool ;
2015-11-30 18:50:23 +03:00
VirtualRouterPool * vrouterpool ;
2015-12-11 17:53:19 +03:00
MarketPlacePool * marketpool ;
MarketPlaceAppPool * apppool ;
2017-01-03 03:22:10 +03:00
VMGroupPool * vmgrouppool ;
2010-04-11 00:19:49 +04:00
2008-06-17 20:27:32 +04:00
// ---------------------------------------------------------------
// Nebula Managers
// ---------------------------------------------------------------
2010-04-11 00:19:49 +04:00
2008-06-17 20:27:32 +04:00
LifeCycleManager * lcm ;
VirtualMachineManager * vmm ;
InformationManager * im ;
TransferManager * tm ;
DispatchManager * dm ;
RequestManager * rm ;
2009-04-04 03:34:33 +04:00
HookManager * hm ;
2010-07-08 21:28:10 +04:00
AuthManager * authm ;
2011-06-22 21:22:52 +04:00
AclManager * aclm ;
2011-03-22 20:21:09 +03:00
ImageManager * imagem ;
2015-12-14 18:47:33 +03:00
MarketPlaceManager * marketm ;
2016-08-18 22:42:24 +03:00
IPAMManager * ipamm ;
2017-04-25 18:15:31 +03:00
RaftManager * raftm ;
2010-04-11 00:19:49 +04:00
2008-06-17 20:27:32 +04:00
// ---------------------------------------------------------------
// Implementation functions
// ---------------------------------------------------------------
2010-04-11 00:19:49 +04:00
2008-06-17 20:27:32 +04:00
friend void nebula_signal_handler ( int sig ) ;
2016-02-03 18:03:22 +03:00
// ---------------------------------------------------------------
// Helper functions
// ---------------------------------------------------------------
/**
* Gets a Generic configuration attribute
* @ param key String that identifies the configuration parameter group name
* @ param name Name of the specific configuration parameter
* @ param value Value of the specific configuration parameter
* @ return a reference to the generated string
*/
int get_conf_attribute (
const std : : string & key ,
const std : : string & name ,
const VectorAttribute * & value ) const ;
2016-08-31 15:52:33 +03:00
/**
* Gets a Generic configuration attribute
* @ param key String that identifies the configuration parameter group name
* @ param name Name of the specific configuration parameter
* @ param value Value of the specific configuration parameter
* @ return a reference to the generated string
*/
template < typename T >
int get_conf_attribute (
const std : : string & key ,
const std : : string & name ,
const std : : string & vname ,
T & value ) const
{
const VectorAttribute * vattr ;
if ( get_conf_attribute ( key , name , vattr ) ! = 0 )
{
return - 1 ;
}
return vattr - > vector_value ( vname , value ) ;
}
2008-06-17 20:27:32 +04:00
} ;
# endif /*NEBULA_H_*/