[one-users] [RFC] Support for multiple oned conf files
Łukasz Oleś
lukaszoles at gmail.com
Sat Nov 27 17:11:19 PST 2010
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: multiple-conf-files.patch
Type: text/x-patch
Size: 2400 bytes
Desc: not available
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20101128/29cd6a18/multiple-conf-files.patch>
More information about the Users
mailing list