2008-06-17 20:27:32 +04:00
/* -------------------------------------------------------------------------- */
2015-09-23 16:03:22 +03:00
/* Copyright 2002-2015, 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_TEMPLATE_H_
# define NEBULA_TEMPLATE_H_
# include "Template.h"
# include <map>
2013-12-21 04:35:51 +04:00
/**
2011-12-14 02:57:56 +04:00
* This class provides the basic abstraction for OpenNebula configuration files
*/
2008-06-17 20:27:32 +04:00
class NebulaTemplate : public Template
2011-12-14 02:57:56 +04:00
{
2008-06-17 20:27:32 +04:00
public :
2011-12-14 02:57:56 +04:00
NebulaTemplate ( const string & etc_location , const char * _conf_name )
{
conf_file = etc_location + _conf_name ;
}
2013-12-21 04:35:51 +04:00
2011-12-14 02:57:56 +04:00
virtual ~ NebulaTemplate ( ) { } ;
/**
* Parse and loads the configuration in the template
*/
int load_configuration ( ) ;
protected :
/**
2013-12-21 04:35:51 +04:00
* Full path to the configuration file
2011-12-14 02:57:56 +04:00
*/
2008-06-17 20:27:32 +04:00
string conf_file ;
2013-12-21 04:35:51 +04:00
2011-12-14 02:57:56 +04:00
/**
* Defaults for the configuration file
*/
2015-12-21 18:45:09 +03:00
multimap < string , Attribute * > conf_default ;
2011-12-14 02:57:56 +04:00
/**
* Sets the defaults value for the template
*/
virtual void set_conf_default ( ) = 0 ;
2015-12-21 18:45:09 +03:00
/**
* Sets the defaults value for multiple attributes
*/
virtual void set_multiple_conf_default ( ) = 0 ;
2011-12-14 02:57:56 +04:00
} ;
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
class OpenNebulaTemplate : public NebulaTemplate
2013-12-21 04:35:51 +04:00
{
2011-12-14 02:57:56 +04:00
public :
OpenNebulaTemplate ( const string & etc_location , const string & _var_location ) :
NebulaTemplate ( etc_location , conf_name ) , var_location ( _var_location )
{ } ;
2013-12-21 04:35:51 +04:00
2011-12-14 02:57:56 +04:00
~ OpenNebulaTemplate ( ) { } ;
2014-11-18 01:17:22 +03:00
/**
* Read or Generate the master key file to encrypt DB data when needed
* this key is added to the configuration of OpenNebula and can be obtained
* through one . system . config
*/
int load_key ( ) ;
2011-12-14 02:57:56 +04:00
private :
/**
* Name for the configuration file , oned . conf
*/
static const char * conf_name ;
/**
* Path for the var directory , for defaults
*/
string var_location ;
2013-12-21 04:35:51 +04:00
2011-12-14 02:57:56 +04:00
/**
* Sets the defaults value for the template
*/
void set_conf_default ( ) ;
2015-12-18 18:22:53 +03:00
2015-12-21 18:45:09 +03:00
/**
* Sets the defaults value for multiple attributes
*/
void set_multiple_conf_default ( ) ;
2015-12-18 18:22:53 +03:00
2015-12-21 19:02:05 +03:00
/**
* register the multiple configuration attributes and clean the
* conf_default hash
*/
void register_multiple_conf_default ( const std : : string & conf_section ) ;
2015-12-18 18:22:53 +03:00
/**
* Sets a default single attribute value
*/
2015-12-21 18:45:09 +03:00
void set_conf_single ( const std : : string & attr , const std : : string & value ) ;
2015-12-21 21:27:26 +03:00
/**
* Sets a the defaults for a DS
*/
void set_conf_ds ( const std : : string & name ,
2015-12-22 16:06:12 +03:00
const std : : string & required_attrs ,
const std : : string & persistent_only ) ;
2015-12-21 21:27:26 +03:00
2015-12-21 18:45:09 +03:00
/**
* Sets a the defaults for a TM
*/
void set_conf_tm ( const std : : string & name ,
const std : : string & ln_target ,
const std : : string & clone_target ,
const std : : string & shared ,
const std : : string & ds_migrate ) ;
2016-02-03 18:03:22 +03:00
/**
* Sets a the defaults for a Market
*/
void set_conf_market ( const std : : string & name ,
const std : : string & required_attrs ) ;
2008-06-17 20:27:32 +04:00
} ;
# endif /*NEBULA_TEMPLATE_H_*/