diff --git a/include/IPAMRequest.h b/include/IPAMRequest.h
index 394cf9e8bb..27a7eb1dcb 100644
--- a/include/IPAMRequest.h
+++ b/include/IPAMRequest.h
@@ -33,8 +33,8 @@ public:
/* IPAM Request constructors */
/* ---------------------------------------------------------------------- */
IPAMRequest(const std::string& _ar_xml) :
- ar_xml(_ar_xml), address_xml("
"
- ""){};
+ ar_xml(_ar_xml), address_xml(""
+ ""){};
IPAMRequest(const std::string& _ar_xml, const std::string& _address_xml) :
ar_xml(_ar_xml), address_xml(_address_xml){};
diff --git a/share/etc/oned.conf b/share/etc/oned.conf
index 31826d3676..196d688a55 100644
--- a/share/etc/oned.conf
+++ b/share/etc/oned.conf
@@ -565,6 +565,24 @@ MARKET_MAD = [
ARGUMENTS = "-t 15 -m http,s3,one"
]
+#*******************************************************************************
+# IPAM Driver Configuration
+#*******************************************************************************
+# Drivers to manage different IPAMs
+# executable: path of the IPAM driver executable, can be an
+# absolute path or relative to $ONE_LOCATION/lib/mads (or
+# /usr/lib/one/mads/ if OpenNebula was installed in /)
+#
+# arguments : for the driver executable
+# -t number of threads, i.e. number of operations at the same time
+# -i IPAM mads separated by commas
+#*******************************************************************************
+
+IPAM_MAD = [
+ EXECUTABLE = "one_ipam",
+ ARGUMENTS = "-t 1 -i dummy"
+]
+
#*******************************************************************************
# Hook Manager Configuration
#*******************************************************************************
diff --git a/src/ipamm/IPAMManager.cc b/src/ipamm/IPAMManager.cc
index 900ee43949..00512f6373 100644
--- a/src/ipamm/IPAMManager.cc
+++ b/src/ipamm/IPAMManager.cc
@@ -37,11 +37,11 @@ extern "C" void * ipamm_action_loop(void *arg)
ipamm = static_cast(arg);
- NebulaLog::log("IpamM",Log::INFO,"IPAM Manager started.");
+ NebulaLog::log("IPM",Log::INFO,"IPAM Manager started.");
ipamm->am.loop(ipamm->timer_period, 0);
- NebulaLog::log("IpamM",Log::INFO,"IPAM Manager stopped.");
+ NebulaLog::log("IPM",Log::INFO,"IPAM Manager stopped.");
return 0;
}
diff --git a/src/ipamm_mad/one_ipam.rb b/src/ipamm_mad/one_ipam.rb
index 08a5645776..c1e99ae9b3 100755
--- a/src/ipamm_mad/one_ipam.rb
+++ b/src/ipamm_mad/one_ipam.rb
@@ -31,6 +31,7 @@ $: << RUBY_LIB_LOCATION
require 'scripts_common'
require 'OpenNebulaDriver'
+require 'rexml/document'
require 'getoptlong'
require 'shellwords'
@@ -99,7 +100,20 @@ class IPAMDriver < OpenNebulaDriver
end
private
- def do_ipam_action(id, ipam, action, arguments)
+ def do_ipam_action(id, action, arguments)
+ begin
+ message = Base64.decode64(arguments)
+ xml_doc = REXML::Document.new(message)
+
+ xml_doc.root
+ ipam = xml_doc.elements['IPAM_DRIVER_ACTION_DATA/AR/IPAM_MAD'].text.strip
+ raise if ipam.empty?
+ rescue
+ send_message(ACTION[action], RESULT[:failure], id,
+ "Cannot perform #{action}, cannot find ipman driver")
+ return
+ end
+
return if not is_available?(ipam, id, action)
path = File.join(@local_scripts_path, ipam)
diff --git a/src/ipamm_mad/remotes/dummy/register_address_range b/src/ipamm_mad/remotes/dummy/register_address_range
index df8c6d23fc..56535609df 100755
--- a/src/ipamm_mad/remotes/dummy/register_address_range
+++ b/src/ipamm_mad/remotes/dummy/register_address_range
@@ -107,7 +107,7 @@ SIZE="${XPATH_ELEMENTS[i++]}"
# IPAM should be contact here. As an example we just "echo" the IP sent by
# OpenNebula or return a fixed sample network
#-------------------------------------------------------------------------------
-if [ -n $IP ]; then
+if [ "x$IP" != "x" ]; then
AR=$(cat < ipam_mads ;
+
+ nebula_configuration->get("IPAM_MAD", ipam_mads);
+
+ ipamm = new IPAMManager(timer_period, ipam_mads);
+ }
+ catch (bad_alloc&)
+ {
+ throw;
+ }
+
+ rc = ipamm->start();
+
+ if ( rc != 0 )
+ {
+ throw runtime_error("Could not start the IPAM Manager");
+ }
+
// -----------------------------------------------------------
// Load mads
// -----------------------------------------------------------
@@ -881,6 +902,11 @@ void Nebula::start(bool bootstrap_only)
goto error_mad;
}
+ if (ipamm->load_mads(0) != 0)
+ {
+ goto error_mad;
+ }
+
if ( authm != 0 )
{
if (authm->load_mads(0) != 0)
@@ -974,6 +1000,7 @@ void Nebula::start(bool bootstrap_only)
hm->finalize();
imagem->finalize();
marketm->finalize();
+ ipamm->finalize();
aclm->finalize();
//sleep to wait drivers???
@@ -987,6 +1014,8 @@ void Nebula::start(bool bootstrap_only)
pthread_join(rm->get_thread_id(),0);
pthread_join(hm->get_thread_id(),0);
pthread_join(imagem->get_thread_id(),0);
+ pthread_join(marketm->get_thread_id(),0);
+ pthread_join(ipamm->get_thread_id(),0);
if(is_federation_slave())
{
diff --git a/src/vnm/AddressRangeIPAM.cc b/src/vnm/AddressRangeIPAM.cc
index aeb7fedf28..e27fbb8599 100644
--- a/src/vnm/AddressRangeIPAM.cc
+++ b/src/vnm/AddressRangeIPAM.cc
@@ -29,12 +29,10 @@ int AddressRangeIPAM::from_vattr(VectorAttribute * attr, std::string& error_msg)
IPAMManager * ipamm = Nebula::instance().get_ipamm();
std::string * ar_xml = attr->to_xml();
- std::string * ar_xml64 = one_util::base64_encode(*ar_xml);
- IPAMRequest ir(*ar_xml64);
+ IPAMRequest ir(*ar_xml);
free(ar_xml);
- free(ar_xml64);
ipamm->trigger(IPAMManager::REGISTER_ADDRESS_RANGE, &ir);