1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-15 18:50:09 +03:00

feature #4446: Activate IPAM. Fix minor bugs

Signed-off-by: Ruben S. Montero <rsmontero@opennebula.org>
This commit is contained in:
Guillaume Oberlé 2016-08-21 19:54:31 +02:00 committed by Ruben S. Montero
parent a5b1862930
commit 34628427ec
7 changed files with 73 additions and 14 deletions

View File

@ -33,8 +33,8 @@ public:
/* IPAM Request constructors */
/* ---------------------------------------------------------------------- */
IPAMRequest(const std::string& _ar_xml) :
ar_xml(_ar_xml), address_xml("<ADDRESS></MAC></IP></IP6_GLOBAL>"
"</IP6_ULA></SIZE></ADDRESS>"){};
ar_xml(_ar_xml), address_xml("<ADDRESS><MAC/><IP/><IP6_GLOBAL/>"
"<IP6_ULA/><SIZE/></ADDRESS>"){};
IPAMRequest(const std::string& _ar_xml, const std::string& _address_xml) :
ar_xml(_ar_xml), address_xml(_address_xml){};

View File

@ -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
#*******************************************************************************

View File

@ -37,11 +37,11 @@ extern "C" void * ipamm_action_loop(void *arg)
ipamm = static_cast<IPAMManager *>(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;
}

View File

@ -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)

View File

@ -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 <<EOF
AR=[
TYPE="IP4",
@ -115,21 +115,21 @@ if [ -n $IP ]; then
IP="$IP",
IPAM_MAD="dummy"
]
EOF
)
EOF
)
else
AR=$(cat <<EOF
AR=[
TYPE="IP4",
IP ="10.0.0.10"
IP ="10.0.0.10",
SIZE="100",
NETWORK_MASK="255.255.255.0",
GATEWAY="10.0.0.1",
DNS="10.0.0.1",
IPAM_MAD="dummy"
]
EOF
)
EOF
)
fi
echo "$AR"

View File

@ -843,6 +843,27 @@ void Nebula::start(bool bootstrap_only)
throw runtime_error("Could not start the Marketplace Manager");
}
// ---- IPAM Manager ----
try
{
vector<const VectorAttribute *> 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())
{

View File

@ -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);