1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-12 09:17:41 +03:00

Merge branch 'master' into feature-1020

This commit is contained in:
ubuntu 2011-12-22 16:08:31 +01:00
commit 2424dfbf79
51 changed files with 655 additions and 298 deletions

View File

@ -97,9 +97,10 @@ private:
* Execute an INSERT or REPLACE Sql query.
* @param db The SQL DB
* @param replace Execute an INSERT or a REPLACE
* @param error_str Returns the error reason, if any
* @return 0 one success
*/
int insert_replace(SqlDB *db, bool replace);
*/
int insert_replace(SqlDB *db, bool replace, string& error_str);
/**
* Bootstraps the database table(s) associated to the Group
@ -119,16 +120,7 @@ private:
*/
int insert(SqlDB *db, string& error_str)
{
int rc;
rc = insert_replace(db, false);
if ( rc != 0 )
{
error_str = "Error inserting Group in DB.";
}
return rc;
return insert_replace(db, false, error_str);
}
/**
@ -138,7 +130,8 @@ private:
*/
int update(SqlDB *db)
{
return insert_replace(db, true);
string error_str;
return insert_replace(db, true, error_str);
}
};

View File

@ -371,9 +371,10 @@ private:
* Execute an INSERT or REPLACE Sql query.
* @param db The SQL DB
* @param replace Execute an INSERT or a REPLACE
* @param error_str Returns the error reason, if any
* @return 0 one success
*/
int insert_replace(SqlDB *db, bool replace);
*/
int insert_replace(SqlDB *db, bool replace, string& error_str);
/**
* Bootstraps the database table(s) associated to the Host
@ -391,14 +392,21 @@ private:
* @param db pointer to the db
* @return 0 on success
*/
int insert(SqlDB *db, string& error_str);
int insert(SqlDB *db, string& error_str)
{
return insert_replace(db, false, error_str);
};
/**
* Writes/updates the Hosts data fields in the database.
* @param db pointer to the db
* @return 0 on success
*/
int update(SqlDB *db);
int update(SqlDB *db)
{
string error_str;
return insert_replace(db, true, error_str);
};
};
#endif /*HOST_H_*/

View File

@ -37,7 +37,8 @@ class HostPool : public PoolSQL
public:
HostPool(SqlDB * db,
vector<const Attribute *> hook_mads,
const string& hook_location);
const string& hook_location,
const string& remotes_location);
~HostPool(){};

View File

@ -349,9 +349,10 @@ private:
* Execute an INSERT or REPLACE Sql query.
* @param db The SQL DB
* @param replace Execute an INSERT or a REPLACE
* @param error_str Returns the error reason, if any
* @return 0 on success
*/
int insert_replace(SqlDB *db, bool replace);
*/
int insert_replace(SqlDB *db, bool replace, string& error_str);
/**
* Bootstraps the database table(s) associated to the Image

View File

@ -152,6 +152,14 @@ public:
*/
int update_from_node(const xmlNodePtr node);
/**
* Validates the xml string
*
* @param xml_doc string to parse
* @return 0 if the xml validates
*/
static int validate_xml(const string &xml_doc);
// ---------------------------------------------------------
// Lex & bison parser for requirements and rank expressions
// ---------------------------------------------------------

View File

@ -48,7 +48,7 @@ protected:
void request_execute(xmlrpc_c::paramList const& _paramList,
RequestAttributes& att);
virtual int user_action(User * user,
virtual int user_action(int user_id,
xmlrpc_c::paramList const& _paramList,
string& error_str ) = 0;
@ -71,7 +71,7 @@ public:
~UserChangePassword(){};
int user_action(User * user,
int user_action(int user_id,
xmlrpc_c::paramList const& _paramList,
string& err);
};
@ -92,7 +92,7 @@ public:
~UserChangeAuth(){};
int user_action(User * user,
int user_action(int user_id,
xmlrpc_c::paramList const& _paramList,
string& err);
};

View File

@ -250,9 +250,10 @@ private:
* Execute an INSERT or REPLACE Sql query.
* @param db The SQL DB
* @param replace Execute an INSERT or a REPLACE
* @param error_str Returns the error reason, if any
* @return 0 one success
*/
int insert_replace(SqlDB *db, bool replace);
int insert_replace(SqlDB *db, bool replace, string& error_str);
/**
* Bootstraps the database table(s) associated to the User
@ -320,7 +321,10 @@ protected:
* @param db pointer to the db
* @return 0 on success
*/
int insert(SqlDB *db, string& error_str);
int insert(SqlDB *db, string& error_str)
{
return insert_replace(db, false, error_str);
};
/**
* Writes/updates the User data fields in the database.
@ -329,7 +333,8 @@ protected:
*/
int update(SqlDB *db)
{
return insert_replace(db, true);
string error_str;
return insert_replace(db, true, error_str);
}
};

View File

@ -102,9 +102,10 @@ private:
* Execute an INSERT or REPLACE Sql query.
* @param db The SQL DB
* @param replace Execute an INSERT or a REPLACE
* @param error_str Returns the error reason, if any
* @return 0 one success
*/
int insert_replace(SqlDB *db, bool replace);
int insert_replace(SqlDB *db, bool replace, string& error_str);
/**
* Bootstraps the database table(s) associated to the VMTemplate
@ -152,6 +153,7 @@ protected:
/**
* Writes the VMTemplate in the database.
* @param db pointer to the db
* @param error_str Returns the error reason, if any
* @return 0 on success
*/
int insert(SqlDB *db, string& error_str);
@ -163,7 +165,8 @@ protected:
*/
int update(SqlDB *db)
{
return insert_replace(db, true);
string err;
return insert_replace(db, true, err);
};
};

View File

@ -834,9 +834,10 @@ private:
* Execute an INSERT or REPLACE Sql query.
* @param db The SQL DB
* @param replace Execute an INSERT or a REPLACE
* @param error_str Returns the error reason, if any
* @return 0 one success
*/
int insert_replace(SqlDB *db, bool replace);
*/
int insert_replace(SqlDB *db, bool replace, string& error_str);
/**
* Updates the VM history record
@ -954,7 +955,8 @@ protected:
*/
int update(SqlDB * db)
{
return insert_replace(db, true);
string error_str;
return insert_replace(db, true, error_str);
}
/**

View File

@ -34,7 +34,8 @@ public:
VirtualMachinePool(SqlDB * db,
vector<const Attribute *> hook_mads,
const string& hook_location);
const string& hook_location,
const string& remotes_location);
~VirtualMachinePool(){};

View File

@ -257,9 +257,10 @@ private:
* Execute an INSERT or REPLACE Sql query.
* @param db The SQL DB
* @param replace Execute an INSERT or a REPLACE
* @param error_str Returns the error reason, if any
* @return 0 on success
*/
int insert_replace(SqlDB *db, bool replace);
int insert_replace(SqlDB *db, bool replace, string& error_str);
/**
* Bootstraps the database table(s) associated to the Virtual Network
@ -355,7 +356,8 @@ private:
*/
int update(SqlDB * db)
{
return insert_replace(db, true);
string error_str;
return insert_replace(db, true, error_str);
}
/**

View File

@ -88,9 +88,10 @@ public:
// Pools
// ------------------------------------------------------------------------
virtual VirtualMachinePool* create_vmpool(SqlDB* db, string hook_location);
virtual VirtualMachinePool* create_vmpool(SqlDB* db,
string hook_location, string vloc);
virtual HostPool* create_hpool(SqlDB* db, string hook_location);
virtual HostPool* create_hpool(SqlDB* db, string hook_location, string vloc);
virtual VirtualNetworkPool* create_vnpool(SqlDB* db,
string mac_prefix,

View File

@ -180,7 +180,8 @@ fi
SHARE_DIRS="$SHARE_LOCATION/examples \
$SHARE_LOCATION/examples/tm"
ETC_DIRS="$ETC_LOCATION/im_ec2 \
ETC_DIRS="$ETC_LOCATION/image \
$ETC_LOCATION/im_ec2 \
$ETC_LOCATION/vmm_ec2 \
$ETC_LOCATION/vmm_exec \
$ETC_LOCATION/tm_shared \
@ -471,6 +472,7 @@ INSTALL_ETC_FILES=(
VMWARE_ETC_FILES:$ETC_LOCATION
VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2
VMM_EXEC_ETC_FILES:$ETC_LOCATION/vmm_exec
IMAGE_DRIVER_FS_ETC_FILES:$ETC_LOCATION/image/
IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2
TM_SHARED_ETC_FILES:$ETC_LOCATION/tm_shared
TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh
@ -738,6 +740,9 @@ VMWARE_TM_SSH_COMMANDS_LIB_FILES="src/tm_mad/vmware-ssh/tm_clone.sh \
# Image Repository drivers, to be installed under $REMOTES_LOCATION/image
# - FS based Image Repository, $REMOTES_LOCATION/image/fs
#-------------------------------------------------------------------------------
IMAGE_DRIVER_FS_ETC_FILES="src/image_mad/remotes/fs/fs.conf"
IMAGE_DRIVER_FS_SCRIPTS="src/image_mad/remotes/fs/cp \
src/image_mad/remotes/fs/mkfs \
src/image_mad/remotes/fs/mv \

View File

@ -0,0 +1,25 @@
[Unit]
Description=OpenNebula Cloud Controller Daemon
After=syslog.target
After=network.target
After=remote_fs.target
Before=one_scheduler.service
# Do not start if the scheduler does not exist
ConditionFileIsExecutable=/usr/bin/mm_sched
!ConditionFileExists=/var/run/one/oned.pid
[Service]
ExecStart=/usr/bin/oned
# Log file location must exist
ExecStartPre=/bin/mkdir -p /var/log/one
ExecStartPre=/bin/chown oneadmin:cloud /var/log/one
ExecStop=/bin/kill -TERM $MAINPID
PIDFile=/var/run/one/oned.pid
Type=forking
[Exec]
Group=cloud
User=oneadmin
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,22 @@
[Unit]
Description=OpenNebula Cloud Scheduler Daemon
After=syslog.target
After=network.target
After=remote_fs.target
After=one.service
BindTo=one.service
!ConditionFileExists=/var/run/one/sched.pid
[Service]
EnvironmentFile=/etc/one/oned.conf
ExecStart=/usr/bin/mm_sched -p $PORT -t 30 -m 300 -d 30 -h 1
ExecStop=/bin/kill -TERM $MAINPID
PIDFile=/var/run/one/sched.pid
Type=simple
[Exec]
Group=cloud
User=oneadmin
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,108 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# 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. #
#--------------------------------------------------------------------------- #
# One time setup for oned
KILL_9_SECONDS=5
LOCK_FILE=/var/lock/one/one
LOCK_FILE_DIR=/var/lock/one
ONE_PID=/var/run/one/oned.pid
ONE_CONF=/etc/one/oned.conf
ONE_DB=/var/lib/one/one.db
ONED=/usr/bin/oned
PORT=$(sed -n '/^[ \t]*PORT/s/^.*PORT\s*=\s*\([0-9]\+\)\s*.*$/\1/p' $ONE_CONF)
if [ $? -ne 0 ]; then
echo "Can not find PORT in $ONE_CONF."
exit 1
fi
if [ ! -d $LOCK_FILE_DIR ]; then
mkdir $LOCK_FILE_DIR > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Could not create lock file directory: $LOCK_FILE_DIR"
exit 1
fi
fi
if [ -f $LOCK_FILE ]; then
if [ -f $ONE_PID ]; then
ONEPID=`cat $ONE_PID`
ps $ONEPID > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "oned already running thus it is configured, nothing to do exiting"
exit 0
fi
fi
echo "Stale .lock detected. Erasing it."
rm $LOCK_FILE
fi
if [ ! -x "$ONED" ]; then
echo "Can not find $ONED."
exit 1
fi
if [ ! -f "$ONE_DB" ]; then
if [ ! -f "$HOME/.one/one_auth" ]; then
if [ -z "$ONE_AUTH" ]; then
echo "You should have ONE_AUTH set the first time you start"
echo "OpenNebula as it is used to set the credentials for"
echo "the administrator user."
exit 1
fi
fi
fi
if [ ! -d /var/lock/one ]; then
mkdir /var/lock/one > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Could not create necessary lock directory: /var/lock/one"
exit 1
fi
fi
# Start the one daemon
$ONED -f 2>&1 &
STARTED=$?
CURPID=$!
if [ $STARTED -ne 0 ]; then
echo "Error executing $ONED : Initial setup failed"
exit 1
fi
# Give oned a chance to do it's thing...
sleep 2
# OK we're all done here
kill -TERM $CURPID > /dev/null 2>&1
counter=0
while ps $CURPID > /dev/null 2>&1; do
let counter=counter+1
if [ $counter -gt $KILL_9_SECONDS ]; then
kill -9 $CURPID > /dev/null 2>&1
break
fi
sleep 1
done
# If the lock file is left over remove it
rm -f /var/lol/one/one

View File

@ -0,0 +1,11 @@
RUNDIR=/var/run/one
if ! [ -d $RUNDIR ]; then
mkdir -p -m 770 $RUNDIR
chown oneadmin:cloud $RUNDIR
fi
LOCKDIR=/var/lock/one
if ! [ -d $LOCKDIR ]; then
mkdir -p -m 770 $LOCKDIR
chown oneadmin:cloud $LOCKDIR
fi

View File

@ -0,0 +1,22 @@
[Unit]
Description=OpenNebula Multi-tenancy Web UI Server
After=syslog.target
After=network.target
After=one.service
After=one_scheduler.service
BindTo=one.service
!ConditionFileExists=/var/lock/one/.ozones.lock
[Service]
ExecStart=/bin/bash -c "/usr/bin/rackup /usr/lib/one/ozones/config.ru -s thin -P /var/run/one/ozones.pid > /var/log/one/ozones-server.log 2>&1"
ExecStartPost=/usr/bin/touch /var/lock/one/.ozones.lock
ExecStop=/bin/kill -INT $MAINPID
PIDFile=/var/run/one/ozones.pid
Type=simple
[Exec]
Group=cloud
User=oneadmin
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,23 @@
[Unit]
Description=OpenNebula Web UI Server
After=syslog.target
After=network.target
After=one.service
After=one_scheduler.service
BindTo=one.service
!ConditionFileExists=/var/lock/one/.sunstone.lock
[Service]
ExecStart=/bin/bash -c "/usr/bin/ruby /usr/lib/one/sunstone/sunstone-server.rb > /var/log/one/sunstone.log 2>&1"
ExecStop=/bin/kill -INT $MAINPID
PIDFile=/var/run/one/sunstone.pid
Type=simple
[Exec]
Group=cloud
User=oneadmin
[Install]
WantedBy=multi-user.target

View File

@ -188,7 +188,7 @@ Configs=[
# Compiles test code with given arguments
def compile(file, args)
logfile="#{file}.log"
command="g++ #{file} -o #{file}.out #{ENV['LDFLAGS']} #{args} 1>>#{logfile} 2>&1"
command="g++ #{file} -o #{file}.out #{ENV['LDFLAGS']} -pthread #{args} 1>>#{logfile} 2>&1"
open(logfile, "a") {|f|
f.write(command+"\n")

View File

@ -1,94 +0,0 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# #
# 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. #
#--------------------------------------------------------------------------- #
import copy
import SCons
xmlrpc_test_program='''
#include <xmlrpc-c/base.hpp>
#include <xmlrpc-c/registry.hpp>
int main(int argc, char *argv[])
{
xmlrpc_c::registry RequestManagerRegistry;
return 0;
}
'''
xmlrpc_config_configurations=[
['pkg-config xmlrpc_server_abyss++ --static --libs', 'pkg-config xmlrpc_client++ --static --libs'],
['pkg-config xmlrpc_server_abyss++ --static --libs', 'pkg-config xmlrpc_client++ --libs ; pkg-config libcurl --libs'],
['pkg-config xmlrpc_server_abyss++ --static --libs', 'xmlrpc-c-config client c++ --libs'],
[r'xmlrpc-c-config abyss-server c++ --libs | tr "\n" " " ; echo -lxmlrpc_server_abyss++ -lxmlrpc++ -lxmlrpc_server++',
r'xmlrpc-c-config abyss-server c++ --libs | tr "\n" " " ; echo -lxmlrpc_server_abyss++ -lxmlrpc++ -lxmlrpc_server++'],
['false', 'false']
]
good_xmlrpc_config=''
good_xmlrpc_client=''
good_xmlrpc_server=''
def CheckXMLRPCConfig(env, conf):
#old_env=env.env.Clone()
env.Message('Checking XMLRPC linking with: "'+conf[0]+'"... ')
try:
env.env.ParseConfig(conf[0])
#env.env.ParseConfig(conf[1])
result=env.TryLink(xmlrpc_test_program, '.cc')
env.Result(result)
print "chejou ao final"
except:
print conf[0]+": vaiserquenon"
result=False
print conf[0]+": parecequefuncionnou"
print result
#env.env=old_env
# Set configuration variables
good_xmlrpc_server=conf[0]
good_xmlrpc_client=conf[1]
env.env['XMLRPC_SERVER']=conf[0]
env.env['XMLRPC_CLIENT']=conf[1]
return result
def CheckXMLRPC(env):
for i in xmlrpc_config_configurations:
res=CheckXMLRPCConfig(env, i)
print "Result:"
print res
if res!=False:
env.env['XMLRPC_SERVER']=good_xmlrpc_server
env.env['XMLRPC_CLIENT']=good_xmlrpc_client
print "funsionou"
return res
return False
def ConfigureXMLRPC(env):
# Check XMLRPC
xmlrpc_conf=Configure(env, custom_tests={'CheckXMLRPC' : CheckXMLRPC})
if not xmlrpc_conf.CheckXMLRPC():
print 'Can not link to XMLRPC libraries.'
Exit(1)
env['XMLRPC_SERVER']=good_xmlrpc_server
env['XMLRPC_CLIENT']=good_xmlrpc_client
xmlrpc_conf=xmlrpc_conf.Finish()

View File

@ -69,7 +69,7 @@ CloudServer.print_configuration(conf)
# Sinatra Configuration
##############################################################################
set :config, conf
set :host, settings.config[:server]
set :bind, settings.config[:server]
set :port, settings.config[:port]
if CloudServer.is_port_open?(settings.config[:server],

View File

@ -79,7 +79,7 @@ if CloudServer.is_port_open?(settings.config[:server],
exit
end
set :host, settings.config[:server]
set :bind, settings.config[:server]
set :port, settings.config[:port]
begin

View File

@ -34,7 +34,7 @@ const char * Group::db_bootstrap = "CREATE TABLE IF NOT EXISTS group_pool ("
/* Group :: Database Access Functions */
/* ************************************************************************ */
int Group::insert_replace(SqlDB *db, bool replace)
int Group::insert_replace(SqlDB *db, bool replace, string& error_str)
{
ostringstream oss;
@ -60,6 +60,11 @@ int Group::insert_replace(SqlDB *db, bool replace)
goto error_body;
}
if ( validate_xml(sql_xml) != 0 )
{
goto error_xml;
}
if ( replace )
{
oss << "REPLACE";
@ -83,9 +88,24 @@ int Group::insert_replace(SqlDB *db, bool replace)
return rc;
error_xml:
db->free_str(sql_name);
db->free_str(sql_xml);
error_str = "Error transforming the Group to XML.";
goto error_common;
error_body:
db->free_str(sql_name);
goto error_generic;
error_name:
goto error_generic;
error_generic:
error_str = "Error inserting Group in DB.";
error_common:
return -1;
}

View File

@ -69,36 +69,7 @@ const char * Host::db_bootstrap = "CREATE TABLE IF NOT EXISTS host_pool ("
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Host::insert(SqlDB *db, string& error_str)
{
int rc;
rc = insert_replace(db, false);
if ( rc != 0 )
{
error_str = "Error inserting Host in DB.";
}
return rc;
}
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Host::update(SqlDB *db)
{
int rc;
rc = insert_replace(db, true);
return rc;
}
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Host::insert_replace(SqlDB *db, bool replace)
int Host::insert_replace(SqlDB *db, bool replace, string& error_str)
{
ostringstream oss;
@ -124,6 +95,11 @@ int Host::insert_replace(SqlDB *db, bool replace)
goto error_body;
}
if ( validate_xml(sql_xml) != 0 )
{
goto error_xml;
}
if(replace)
{
oss << "REPLACE";
@ -149,9 +125,24 @@ int Host::insert_replace(SqlDB *db, bool replace)
return rc;
error_xml:
db->free_str(sql_hostname);
db->free_str(sql_xml);
error_str = "Error transforming the Group to XML.";
goto error_common;
error_body:
db->free_str(sql_hostname);
goto error_generic;
error_hostname:
goto error_generic;
error_generic:
error_str = "Error inserting Group in DB.";
error_common:
return -1;
}

View File

@ -19,6 +19,7 @@
/* ************************************************************************** */
#include <stdexcept>
#include <sstream>
#include "HostPool.h"
#include "HostHook.h"
@ -30,7 +31,8 @@
HostPool::HostPool(SqlDB* db,
vector<const Attribute *> hook_mads,
const string& hook_location)
const string& hook_location,
const string& remotes_location)
: PoolSQL(db,Host::table)
{
// ------------------ Initialize Hooks fot the pool ----------------------
@ -88,8 +90,19 @@ HostPool::HostPool(SqlDB* db,
if (cmd[0] != '/')
{
cmd = hook_location + cmd;
}
ostringstream cmd_os;
if ( remote )
{
cmd_os << hook_location << "/" << cmd;
}
else
{
cmd_os << remotes_location << "/hooks/" << cmd;
}
cmd = cmd_os.str();
}
if ( on == "CREATE" )
{

View File

@ -155,7 +155,7 @@ protected:
{
vector<const Attribute *> hook;
return new HostPool(db,hook,"./");
return new HostPool(db,hook,"./", "./");
};
int allocate(int index)

View File

@ -42,7 +42,7 @@ public:
// Pools
// -----------------------------------------------------------
HostPool* create_hpool(SqlDB* db, string hook_location)
HostPool* create_hpool(SqlDB* db, string hook_location, string var_location)
{
map<string,string> hook_value;
VectorAttribute * hook;
@ -81,7 +81,7 @@ public:
host_hooks.push_back(hook);
return new HostPool(db, host_hooks, hook_location);
return new HostPool(db, host_hooks, hook_location, var_location);
}
};

View File

@ -190,12 +190,7 @@ int Image::insert(SqlDB *db, string& error_str)
// Insert the Image
//--------------------------------------------------------------------------
rc = insert_replace(db, false);
if ( rc == -1 )
{
error_str = "Error inserting Image in DB.";
}
rc = insert_replace(db, false, error_str);
return rc;
@ -237,13 +232,14 @@ error_common:
int Image::update(SqlDB *db)
{
return insert_replace(db, true);;
string error_str;
return insert_replace(db, true, error_str);
}
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Image::insert_replace(SqlDB *db, bool replace)
int Image::insert_replace(SqlDB *db, bool replace, string& error_str)
{
ostringstream oss;
@ -270,6 +266,11 @@ int Image::insert_replace(SqlDB *db, bool replace)
goto error_body;
}
if ( validate_xml(sql_xml) != 0 )
{
goto error_xml;
}
if(replace)
{
oss << "REPLACE";
@ -296,9 +297,24 @@ int Image::insert_replace(SqlDB *db, bool replace)
return rc;
error_xml:
db->free_str(sql_name);
db->free_str(sql_xml);
error_str = "Error transforming the Image to XML.";
goto error_common;
error_body:
db->free_str(sql_name);
goto error_generic;
error_name:
goto error_generic;
error_generic:
error_str = "Error inserting Image in DB.";
error_common:
return -1;
}

View File

@ -0,0 +1,38 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# #
# 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. #
#--------------------------------------------------------------------------- #
# PRESERVE BASH SYNTAX
#*******************************************************************************
# Configuration File for File-System based Image Repositories
#-------------------------------------------------------------------------------
# IMAGE_REPOSITORY: Path where the images will be stored. If not defined
# defaults to /var/lib/one/images or $ONE_LOCATION/var/images
#
# RESTRICTED_DIRS: Paths that can not be used to register images. A space
# separated list of paths. This prevents users to access important files like
# oned.db or /etc/shadow. OpenNebula will automatically add its configuration
# dirs:/var/lib/one, /etc/one and oneadmin's home ($HOME).
#
# SAFE_DIRS: Paths that are safe to specify image paths. This will allow you to
# open specific paths within RESTRICTED_DIRS
#*******************************************************************************
#IMAGE_REPOSITORY_PATH=/var/lib/one/images
RESTRICTED_DIRS="/etc/"
SAFE_DIRS="$HOME/public/"

View File

@ -22,12 +22,6 @@
# - RESTRICTED_DIRS: Paths that can not be used to register images
# - SAFE_DIRS: Paths that are safe to specify image paths
#------------------------------------------------------------------------------
if [ -z "${ONE_LOCATION}" ]; then
export IMAGE_REPOSITORY_PATH=/var/lib/one/images
else
export IMAGE_REPOSITORY_PATH=$ONE_LOCATION/var/images
fi
if [ -z "${ONE_LOCATION}" ]; then
VAR_LOCATION=/var/lib/one/
ETC_LOCATION=/etc/one/
@ -36,8 +30,23 @@ else
ETC_LOCATION=$ONE_LOCATION/etc/
fi
export RESTRICTED_DIRS="$VAR_LOCATION $ETC_LOCATION $HOME/ /etc/"
export SAFE_DIRS="$HOME/public/"
CONF_FILE=$ETC_LOCATION/image/fs.conf
source $CONF_FILE
if [ -z "${IMAGE_REPOSITORY_PATH}" ]; then
if [ -z "${ONE_LOCATION}" ]; then
IMAGE_REPOSITORY_PATH=/var/lib/one/images
else
IMAGE_REPOSITORY_PATH=$ONE_LOCATION/var/images
fi
fi
RESTRICTED_DIRS="$VAR_LOCATION $ETC_LOCATION $HOME/ $RESTRICTED_DIRS"
export IMAGE_REPOSITORY_PATH
export RESTRICTED_DIRS
export SAFE_DIRS
#------------------------------------------------------------------------------
# Function used to generate Image names, you should not need to override this
@ -86,7 +95,6 @@ function check_restricted {
# Change the permissions of all the files inside directoriers (= VMware disks)
function fix_owner_perms {
find $IMAGE_REPOSITORY_PATH -type d \
-mindepth 1 \
-maxdepth 1 \

View File

@ -280,15 +280,17 @@ void Nebula::start()
nebula_configuration->get("VM_HOOK", vm_hooks);
nebula_configuration->get("HOST_HOOK", host_hooks);
vmpool = new VirtualMachinePool(db, vm_hooks, hook_location);
hpool = new HostPool(db, host_hooks, hook_location);
vmpool = new VirtualMachinePool(db,
vm_hooks,
hook_location,
remotes_location);
hpool = new HostPool(db, host_hooks, hook_location, remotes_location);
nebula_configuration->get("MAC_PREFIX", mac_prefix);
nebula_configuration->get("NETWORK_SIZE", size);
vnpool = new VirtualNetworkPool(db,mac_prefix,size);
gpool = new GroupPool(db);
gpool = new GroupPool(db);
nebula_configuration->get("SESSION_EXPIRATION_TIME", expiration_time);
upool = new UserPool(db, expiration_time);
@ -301,7 +303,7 @@ void Nebula::start()
default_image_type,
default_device_prefix);
tpool = new VMTemplatePool(db);
tpool = new VMTemplatePool(db);
}
catch (exception&)
{

View File

@ -109,7 +109,7 @@ end
# Sinatra Configuration
##############################################################################
use Rack::Session::Pool, :key => 'ozones'
set :host, config[:host]
set :bind, config[:host]
set :port, config[:port]
set :show_exceptions, false

View File

@ -31,7 +31,7 @@ void RequestManagerUser::
return;
}
user = static_cast<User *>(pool->get(id,true));
user = static_cast<User *>(pool->get(id,false));
if ( user == 0 )
{
@ -42,7 +42,7 @@ void RequestManagerUser::
return;
}
if ( user_action(user,paramList,error_str) < 0 )
if ( user_action(id,paramList,error_str) < 0 )
{
failure_response(INTERNAL, request_error(error_str,""), att);
return;
@ -54,12 +54,20 @@ void RequestManagerUser::
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int UserChangePassword::user_action(User * user,
int UserChangePassword::user_action(int user_id,
xmlrpc_c::paramList const& paramList,
string& error_str)
{
string new_pass = xmlrpc_c::value_string(paramList.getString(2));
User * user;
user = static_cast<User *>(pool->get(user_id,true));
if ( user == 0 )
{
return -1;
}
if (user->get_auth_driver() == UserPool::CORE_AUTH)
{
@ -81,14 +89,23 @@ int UserChangePassword::user_action(User * user,
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int UserChangeAuth::user_action(User * user,
int UserChangeAuth::user_action(int user_id,
xmlrpc_c::paramList const& paramList,
string& error_str)
{
string new_auth = xmlrpc_c::value_string(paramList.getString(2));
string new_pass = xmlrpc_c::value_string(paramList.getString(3));
int rc = 0;
int rc = 0;
User * user;
user = static_cast<User *>(pool->get(user_id,true));
if ( user == 0 )
{
return -1;
}
if ( !new_pass.empty() )
{

View File

@ -83,10 +83,11 @@ var create_host_tmpl =
<div class="manager clear" id="vnm_mads">\
<label>Virtual Network Manager:</label>\
<select id="vnm_mad" name="vn">\
<option value="dummy">Dummy</option>\
<option value="etables">Etables</option>\
<option value="ovswitch">Open vSwitch</option>\
<option value="dummy">Default (dummy)</option>\
<option value="fw">Firewall</option>\
<option value="802.1Q">802.1Q</option>\
<option value="ebtables">Ebtables</option>\
<option value="ovswitch">Open vSwitch</option>\
</select>\
</div>\
<div class="manager clear" id="tm_mads">\

View File

@ -90,8 +90,8 @@ var create_image_tmpl =
<div class="img_param">\
<label for="img_bus">Bus:</label>\
<select name="img_bus" id="img_bus">\
<option value="IDE">IDE</option>\
<option value="SCSI">SCSI</option>\
<option value="ide">IDE</option>\
<option value="scsi">SCSI</option>\
<option value="virtio">Virtio (KVM)</option>\
</select>\
<div class="tip">Type of disk device to emulate.</div>\

View File

@ -758,7 +758,12 @@ function setupCreateVNetDialog() {
//for each specified lease we prepare the JSON object
$.each(leases,function(){
leases_obj.push({"ip": $(this).val() });
var lease_str = $(this).val().split(",");
if (lease_str[1])
leases_obj.push({"ip": lease_str[0],
"mac": lease_str[1]});
else
leases_obj.push({"ip": lease_str[0] });
});
//and construct the final data for the request

View File

@ -65,7 +65,7 @@ end
##############################################################################
use Rack::Session::Pool, :key => 'sunstone'
set :config, conf
set :host, settings.config[:host]
set :bind, settings.config[:host]
set :port, settings.config[:port]
begin

View File

@ -423,18 +423,18 @@ union yyalloc
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 6
#define YYFINAL 7
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 15
#define YYLAST 16
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 10
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 4
#define YYNNTS 5
/* YYNRULES -- Number of rules. */
#define YYNRULES 8
#define YYNRULES 10
/* YYNRULES -- Number of states. */
#define YYNSTATES 19
#define YYNSTATES 20
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
@ -480,22 +480,24 @@ static const yytype_uint8 yytranslate[] =
YYRHS. */
static const yytype_uint8 yyprhs[] =
{
0, 0, 3, 5, 8, 12, 18, 21, 25
0, 0, 3, 4, 6, 8, 11, 15, 21, 24,
28
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] =
{
11, 0, -1, 12, -1, 11, 12, -1, 9, 3,
8, -1, 9, 3, 5, 13, 6, -1, 9, 7,
-1, 9, 3, 8, -1, 13, 4, 9, 3, 8,
-1
11, 0, -1, -1, 12, -1, 13, -1, 12, 13,
-1, 9, 3, 8, -1, 9, 3, 5, 14, 6,
-1, 9, 7, -1, 9, 3, 8, -1, 14, 4,
9, 3, 8, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
0, 94, 94, 95, 98, 108, 121, 133, 146
0, 94, 94, 95, 98, 99, 102, 112, 125, 137,
150
};
#endif
@ -505,8 +507,8 @@ static const yytype_uint8 yyrline[] =
static const char *const yytname[] =
{
"$end", "error", "$undefined", "EQUAL", "COMMA", "OBRACKET", "CBRACKET",
"EQUAL_EMPTY", "STRING", "VARIABLE", "$accept", "template", "attribute",
"array_val", 0
"EQUAL_EMPTY", "STRING", "VARIABLE", "$accept", "template_file",
"template", "attribute", "array_val", 0
};
#endif
@ -522,13 +524,15 @@ static const yytype_uint16 yytoknum[] =
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
0, 10, 11, 11, 12, 12, 12, 13, 13
0, 10, 11, 11, 12, 12, 13, 13, 13, 14,
14
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 1, 2, 3, 5, 2, 3, 5
0, 2, 0, 1, 1, 2, 3, 5, 2, 3,
5
};
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
@ -536,29 +540,29 @@ static const yytype_uint8 yyr2[] =
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
0, 0, 0, 2, 0, 6, 1, 3, 0, 4,
0, 0, 0, 0, 5, 7, 0, 0, 8
2, 0, 0, 3, 4, 0, 8, 1, 5, 0,
6, 0, 0, 0, 0, 7, 9, 0, 0, 10
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
-1, 2, 3, 11
-1, 2, 3, 4, 12
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
#define YYPACT_NINF -8
#define YYPACT_NINF -9
static const yytype_int8 yypact[] =
{
-7, -2, 0, -8, -1, -8, -8, -8, -6, -8,
7, 2, 3, 4, -8, -8, 9, 6, -8
-8, -3, 2, -8, -9, -2, -9, -9, -9, -1,
-9, 6, 1, 3, 4, -9, -9, 7, 8, -9
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
-8, -8, 13, -8
-9, -9, -9, 9, -9
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@ -567,28 +571,28 @@ static const yytype_int8 yypgoto[] =
#define YYTABLE_NINF -1
static const yytype_uint8 yytable[] =
{
6, 4, 1, 10, 8, 5, 13, 9, 14, 1,
12, 15, 17, 16, 18, 7
5, 1, 7, 9, 6, 14, 10, 15, 11, 13,
18, 16, 8, 17, 0, 0, 19
};
#define yypact_value_is_default(yystate) \
((yystate) == (-8))
((yystate) == (-9))
#define yytable_value_is_error(yytable_value) \
YYID (0)
static const yytype_uint8 yycheck[] =
static const yytype_int8 yycheck[] =
{
0, 3, 9, 9, 5, 7, 4, 8, 6, 9,
3, 8, 3, 9, 8, 2
3, 9, 0, 5, 7, 4, 8, 6, 9, 3,
3, 8, 3, 9, -1, -1, 8
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
0, 9, 11, 12, 3, 7, 0, 12, 5, 8,
9, 13, 3, 4, 6, 8, 9, 3, 8
0, 9, 11, 12, 13, 3, 7, 0, 13, 5,
8, 9, 14, 3, 4, 6, 8, 9, 3, 8
};
#define yyerrok (yyerrstatus = 0)
@ -1485,10 +1489,10 @@ yyreduce:
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 4:
case 6:
/* Line 1806 of yacc.c */
#line 99 "template_syntax.y"
#line 103 "template_syntax.y"
{
Attribute * pattr;
string name((yyvsp[(1) - (3)].val_str));
@ -1500,10 +1504,10 @@ yyreduce:
}
break;
case 5:
case 7:
/* Line 1806 of yacc.c */
#line 109 "template_syntax.y"
#line 113 "template_syntax.y"
{
Attribute * pattr;
string name((yyvsp[(1) - (5)].val_str));
@ -1518,10 +1522,10 @@ yyreduce:
}
break;
case 6:
case 8:
/* Line 1806 of yacc.c */
#line 122 "template_syntax.y"
#line 126 "template_syntax.y"
{
Attribute * pattr;
string name((yyvsp[(1) - (2)].val_str));
@ -1533,10 +1537,10 @@ yyreduce:
}
break;
case 7:
case 9:
/* Line 1806 of yacc.c */
#line 134 "template_syntax.y"
#line 138 "template_syntax.y"
{
map<string,string>* vattr;
string name((yyvsp[(1) - (3)].val_str));
@ -1551,10 +1555,10 @@ yyreduce:
}
break;
case 8:
case 10:
/* Line 1806 of yacc.c */
#line 147 "template_syntax.y"
#line 151 "template_syntax.y"
{
string name((yyvsp[(3) - (5)].val_str));
string value((yyvsp[(5) - (5)].val_str));
@ -1572,7 +1576,7 @@ yyreduce:
/* Line 1806 of yacc.c */
#line 1576 "template_syntax.cc"
#line 1580 "template_syntax.cc"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@ -1810,7 +1814,7 @@ yyreturn:
/* Line 2067 of yacc.c */
#line 160 "template_syntax.y"
#line 164 "template_syntax.y"
string& unescape (string &str)

View File

@ -91,7 +91,11 @@ extern "C"
%%
template: attribute
template_file :
| template
;
template: attribute
| template attribute
;

View File

@ -201,12 +201,12 @@ void Nebula::start()
if (tester->need_vm_pool)
{
vmpool = tester->create_vmpool(db,hook_location);
vmpool = tester->create_vmpool(db,hook_location,var_location);
}
if (tester->need_host_pool)
{
hpool = tester->create_hpool(db,hook_location);
hpool = tester->create_hpool(db,hook_location,var_location);
}
if (tester->need_vnet_pool)

View File

@ -18,16 +18,17 @@
NebulaTest* NebulaTest::the_tester;
VirtualMachinePool* NebulaTest::create_vmpool(SqlDB* db, string hook_location)
VirtualMachinePool* NebulaTest::create_vmpool(SqlDB* db, string hook_location,
string vloc)
{
vector<const Attribute *> hooks;
return new VirtualMachinePool(db, hooks, hook_location);
return new VirtualMachinePool(db, hooks, hook_location, vloc);
}
HostPool* NebulaTest::create_hpool(SqlDB* db, string hook_location)
HostPool* NebulaTest::create_hpool(SqlDB* db, string hook_location, string vloc)
{
vector<const Attribute *> hooks;
return new HostPool(db, hooks, hook_location);
return new HostPool(db, hooks, hook_location, vloc);
}
VirtualNetworkPool* NebulaTest::create_vnpool(SqlDB* db, string mac_prefix, int size)

View File

@ -44,25 +44,7 @@ const char * User::db_bootstrap = "CREATE TABLE IF NOT EXISTS user_pool ("
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int User::insert(SqlDB *db, string& error_str)
{
int rc;
rc = insert_replace(db, false);
if ( rc != 0 )
{
error_str = "Error inserting User in DB.";
return rc;
}
return 0;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int User::insert_replace(SqlDB *db, bool replace)
int User::insert_replace(SqlDB *db, bool replace, string& error_str)
{
ostringstream oss;
@ -88,6 +70,11 @@ int User::insert_replace(SqlDB *db, bool replace)
goto error_body;
}
if ( validate_xml(sql_xml) != 0 )
{
goto error_xml;
}
// Construct the SQL statement to Insert or Replace
if(replace)
{
@ -110,9 +97,24 @@ int User::insert_replace(SqlDB *db, bool replace)
return rc;
error_xml:
db->free_str(sql_username);
db->free_str(sql_xml);
error_str = "Error transforming the User to XML.";
goto error_common;
error_body:
db->free_str(sql_username);
goto error_generic;
error_username:
goto error_generic;
error_generic:
error_str = "Error inserting User in DB.";
error_common:
return -1;
}

View File

@ -281,7 +281,7 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
// Insert the VM
// ------------------------------------------------------------------------
rc = insert_replace(db, false);
rc = insert_replace(db, false, error_str);
if ( rc != 0 )
{
@ -291,7 +291,6 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
return 0;
error_update:
error_str = "Can not insert VM in the database.";
goto error_rollback;
error_context:
@ -506,7 +505,7 @@ int VirtualMachine::parse_requirements(string& error_str)
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int VirtualMachine::insert_replace(SqlDB *db, bool replace)
int VirtualMachine::insert_replace(SqlDB *db, bool replace, string& error_str)
{
ostringstream oss;
int rc;
@ -520,7 +519,7 @@ int VirtualMachine::insert_replace(SqlDB *db, bool replace)
if ( sql_deploy_id == 0 )
{
goto error_deploy;
goto error_generic;
}
sql_name = db->escape_str(name.c_str());
@ -537,6 +536,11 @@ int VirtualMachine::insert_replace(SqlDB *db, bool replace)
goto error_body;
}
if ( validate_xml(sql_xml) != 0 )
{
goto error_xml;
}
if(replace)
{
oss << "REPLACE";
@ -564,12 +568,27 @@ int VirtualMachine::insert_replace(SqlDB *db, bool replace)
return rc;
error_xml:
db->free_str(sql_deploy_id);
db->free_str(sql_name);
db->free_str(sql_xml);
error_str = "Error transforming the VM to XML.";
goto error_common;
error_body:
db->free_str(sql_deploy_id);
db->free_str(sql_name);
goto error_generic;
error_name:
db->free_str(sql_deploy_id);
error_deploy:
goto error_generic;
error_generic:
error_str = "Error inserting VM in DB.";
error_common:
return -1;
}

View File

@ -26,7 +26,8 @@
VirtualMachinePool::VirtualMachinePool(SqlDB * db,
vector<const Attribute *> hook_mads,
const string& hook_location)
const string& hook_location,
const string& remotes_location)
: PoolSQL(db,VirtualMachine::table)
{
const VectorAttribute * vattr;
@ -82,8 +83,19 @@ VirtualMachinePool::VirtualMachinePool(SqlDB * db,
if (cmd[0] != '/')
{
cmd = hook_location + cmd;
}
ostringstream cmd_os;
if ( remote )
{
cmd_os << hook_location << "/" << cmd;
}
else
{
cmd_os << remotes_location << "/hooks/" << cmd;
}
cmd = cmd_os.str();
}
if ( on == "CREATE" )
{

View File

@ -85,7 +85,7 @@ class VirtualMachinePoolFriend : public VirtualMachinePool
{
public:
VirtualMachinePoolFriend(SqlDB * db, vector<const Attribute *> hook_mads):
VirtualMachinePool(db, hook_mads, "./")
VirtualMachinePool(db, hook_mads, "./", "./")
{};

View File

@ -113,12 +113,7 @@ int VMTemplate::insert(SqlDB *db, string& error_str)
// Insert the Template
// ------------------------------------------------------------------------
rc = insert_replace(db, false);
if ( rc != 0 )
{
error_str = "Error inserting Template in DB.";
}
rc = insert_replace(db, false, error_str);
return rc;
}
@ -126,7 +121,7 @@ int VMTemplate::insert(SqlDB *db, string& error_str)
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int VMTemplate::insert_replace(SqlDB *db, bool replace)
int VMTemplate::insert_replace(SqlDB *db, bool replace, string& error_str)
{
ostringstream oss;
@ -152,6 +147,11 @@ int VMTemplate::insert_replace(SqlDB *db, bool replace)
goto error_body;
}
if ( validate_xml(sql_xml) != 0 )
{
goto error_xml;
}
if(replace)
{
oss << "REPLACE";
@ -178,9 +178,24 @@ int VMTemplate::insert_replace(SqlDB *db, bool replace)
return rc;
error_xml:
db->free_str(sql_name);
db->free_str(sql_xml);
error_str = "Error transforming the Template to XML.";
goto error_common;
error_body:
db->free_str(sql_name);
goto error_generic;
error_name:
goto error_generic;
error_generic:
error_str = "Error inserting Template in DB.";
error_common:
return -1;
}

View File

@ -98,7 +98,10 @@ int LibVirtDriver::deployment_description_kvm(
// Starting XML document
// ------------------------------------------------------------------------
file << "<domain type='" << emulator << "'>" << endl;
file << "<domain type='"
<< emulator
<< "' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>"
<< endl;
// ------------------------------------------------------------------------
// Domain name
@ -505,7 +508,7 @@ int LibVirtDriver::deployment_description_kvm(
if (!filter.empty())
{
the_filter = &filter;
}
}
else if (!default_filter.empty())
{
the_filter = &default_filter;
@ -514,9 +517,9 @@ int LibVirtDriver::deployment_description_kvm(
if ( the_filter != 0 )
{
file <<"\t\t\t<filterref filter='"<< *the_filter <<"'>"<<endl;
file << "\t\t\t\t<parameter name='IP' value='"
file << "\t\t\t\t<parameter name='IP' value='"
<< ip << "'/>" << endl;
file << "\t\t\t</filterref>" << endl;
file << "\t\t\t</filterref>" << endl;
}
}

View File

@ -228,7 +228,7 @@ int VirtualNetwork::insert(SqlDB * db, string& error_str)
TO_UPPER(vlan_attr);
vlan = (vlan_attr == "YES");
vlan = (vlan_attr == "YES") || (vlan_attr.empty() && !phydev.empty());
// ------------ BRIDGE --------------------
@ -302,7 +302,7 @@ int VirtualNetwork::insert(SqlDB * db, string& error_str)
//--------------------------------------------------------------------------
// Insert the Virtual Network
//--------------------------------------------------------------------------
rc = insert_replace(db, false);
rc = insert_replace(db, false, error_str);
if ( rc != 0 )
{
@ -328,7 +328,7 @@ error_bridge:
goto error_common;
error_update:
ose << "Can not update Virtual Network.";
ose << error_str;
goto error_common;
error_ranged:
@ -347,7 +347,7 @@ error_common:
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int VirtualNetwork::insert_replace(SqlDB *db, bool replace)
int VirtualNetwork::insert_replace(SqlDB *db, bool replace, string& error_str)
{
ostringstream oss;
int rc;
@ -373,6 +373,11 @@ int VirtualNetwork::insert_replace(SqlDB *db, bool replace)
goto error_body;
}
if ( validate_xml(sql_xml) != 0 )
{
goto error_xml;
}
// Construct the SQL statement to Insert or Replace
if(replace)
{
@ -398,10 +403,24 @@ int VirtualNetwork::insert_replace(SqlDB *db, bool replace)
return rc;
error_xml:
db->free_str(sql_name);
db->free_str(sql_xml);
error_str = "Error transforming the Virtual Network to XML.";
goto error_common;
error_body:
db->free_str(sql_name);
goto error_generic;
error_name:
goto error_generic;
error_generic:
error_str = "Error inserting Virtual Network in DB.";
error_common:
return -1;
}

View File

@ -123,6 +123,8 @@ class OpenNebulaFirewall < OpenNebulaNetwork
def filter_ports(chain, protocol, range, policy)
policy = policy.to_s.upcase
range.gsub!(/\s+/,"")
if range? range
rule "-A #{chain} -p #{protocol} -m multiport --dports #{range} -j #{policy}"
end

View File

@ -378,6 +378,24 @@ int ObjectXML::update_from_node(const xmlNodePtr node)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int ObjectXML::validate_xml(const string &xml_doc)
{
xmlDocPtr tmp_xml = 0;
tmp_xml = xmlParseMemory (xml_doc.c_str(),xml_doc.length());
if (tmp_xml == 0)
{
return -1;
}
xmlFreeDoc(tmp_xml);
return 0;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void ObjectXML::xml_parse(const string &xml_doc)
{
xml = xmlParseMemory (xml_doc.c_str(),xml_doc.length());