[one-users] [RFC] Support for multiple oned conf files

Ruben S. Montero rubensm at dacya.ucm.es
Sun Nov 28 11:41:29 PST 2010


Hi Łukasz,

I do not really see any problem to apply this patch, We'll schedule
this for 2.2, we rather not change the etc in a 2.0 maintenance
release...

Thanks your valuable contributions! :)

Ruben

On Sun, Nov 28, 2010 at 2:11 AM, Łukasz Oleś <lukaszoles at gmail.com> wrote:
> Hi,
>
> It searches for aditional conf files in etc_location/oned.conf.d/ dir.
>
> This patch is valuable mainly for distributions like Debian/Ubuntu where one
> package cannot modify other packages configs. Now when I create custom
> transfer manager I can create deb package with separate configuration file and
> easily install it.
>
> See patch bellow and in attachment, it was build against latest one-2.0
> branch. This patch requires boost-filesystem. It can by applied by 'git
> apply'.
>
>  src/nebula/NebulaTemplate.cc |   38 ++++++++++++++++++++++++++++++++++++++
>  src/nebula/SConstruct        |    3 ++-
>  2 files changed, 40 insertions(+), 1 deletions(-)
>
> diff --git a/src/nebula/NebulaTemplate.cc b/src/nebula/NebulaTemplate.cc
> index c9c1a5b..227515b 100644
> --- a/src/nebula/NebulaTemplate.cc
> +++ b/src/nebula/NebulaTemplate.cc
> @@ -16,8 +16,13 @@
>
>  #include "NebulaTemplate.h"
>  #include "Nebula.h"
> +#include <boost/filesystem/operations.hpp>
> +#include <boost/filesystem/path.hpp>
> +#include <boost/progress.hpp>
> +#include <iostream>
>
>  using namespace std;
> +namespace fs = boost::filesystem;
>
>  /* --------------------------------------------------------------------------
> */
>  /* --------------------------------------------------------------------------
> */
> @@ -175,6 +180,39 @@ int NebulaTemplate::load_configuration()
>         return -1;
>     }
>
> +    string full_path, tmp = conf_file + ".d";
> +    fs::path extra_conf_dir = fs::system_complete(fs::path(tmp.c_str()));
> +
> +    if (fs::is_directory(extra_conf_dir))
> +    {
> +        fs::directory_iterator end_iter;
> +        for (fs::directory_iterator dir_itr(extra_conf_dir);
> +             dir_itr != end_iter;
> +             ++dir_itr)
> +        {
> +            try
> +            {
> +                if (fs::is_regular_file(dir_itr->status()))
> +                {
> +                    full_path = conf_file + ".d/" + dir_itr-
>>path().filename();
> +                    rc = parse(full_path.c_str(), &error);
> +                    if ( rc != 0 && error != 0)
> +                    {
> +                        cout << "\nError while parsing" << full_path << "
> file:\n" << error << endl;
> +
> +                        free(error);
> +
> +                        return -1;
> +                    }
> +                }
> +            }
> +            catch ( const std::exception & ex )
> +            {
> +                std::cout << dir_itr->path().filename() << " " << ex.what()
> << std::endl;
> +            }
> +        }
> +    }
> +
>     for(iter=conf_default.begin();iter!=conf_default.end();)
>     {
>         aname = iter->first;
> diff --git a/src/nebula/SConstruct b/src/nebula/SConstruct
> index ebc9f81..9f1366a 100644
> --- a/src/nebula/SConstruct
> +++ b/src/nebula/SConstruct
> @@ -51,7 +51,8 @@ env.Append(LIBS=[
>     'nebula_common',
>     'nebula_sql',
>     'nebula_log',
> -    'crypto'
> +    'crypto',
> +    'boost_filesystem',
>  ])
>
>  # Sources to generate the library
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opennebula.org
> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>
>



-- 
Dr. Ruben Santiago Montero
Associate Professor (Profesor Titular), Complutense University of Madrid

URL: http://dsa-research.org/doku.php?id=people:ruben
Weblog: http://blog.dsa-research.org/?author=7



More information about the Users mailing list