Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Hector Sanjuan committed 2011-09-28 17:43:26 +02:00
commit cbfb87b39d
21 files changed
+309 -61

No files matched your search

+4 -1
View File
@@ -652,8 +652,11 @@ IMAGE_DRIVER_FS_SCRIPTS="src/image_mad/remotes/fs/cp \
#-------------------------------------------------------------------------------
ONEDB_MIGRATOR_FILES="src/onedb/2.0_to_2.9.80.rb \
src/onedb/2.9.80_to_2.9.85.rb \
src/onedb/2.9.85_to_2.9.90.rb \
src/onedb/2.9.90_to_3.0.rb \
src/onedb/onedb.rb \
src/onedb/onedb_backend.rb"
src/onedb/onedb_backend.rb \
src/onedb/Configuration.rb"
#-------------------------------------------------------------------------------
# Configuration files for OpenNebula, to be installed under $ETC_LOCATION
+5 -1
View File
@@ -9,12 +9,16 @@ DEFAULT=%w{optional sunstone quota cloud ozones_server acct}
if defined?(RUBY_VERSION) && RUBY_VERSION>="1.8.7"
SQLITE='sqlite3'
# xmlparser gem is not compatible with ruby 1.9
OPTIONAL=%w{nokogiri}
else
SQLITE='sqlite3-ruby --version 1.2.0'
OPTIONAL=%w{nokogir xmlparser}
end
GROUPS={
:optional => %w{nokogiri xmlparser},
:optional => OPTIONAL,
:quota => [SQLITE, 'sequel'],
:sunstone => ['json', 'rack', 'sinatra', 'thin', 'sequel', SQLITE],
:cloud => %w{amazon-ec2 rack sinatra thin uuid curb},
@@ -158,31 +158,38 @@ public class Client{
String[] token = oneSecret.split(":");
if(token.length != 2 )
if ( token.length > 2 )
{
oneAuth = oneSecret;
}
else if ( token.lenght == 2 )
{
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] digest = md.digest(token[1].getBytes());
String hash = "";
for(byte aux : digest)
{
int b = aux & 0xff;
if (Integer.toHexString(b).length() == 1)
{
hash += "0";
}
hash += Integer.toHexString(b);
}
oneAuth = token[0] + ":" + hash;
}
else
{
throw new ClientConfigurationException(
"Wrong format for authorization string: "
+ oneSecret + "\nFormat expected is user:password");
}
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] digest = md.digest(token[1].getBytes());
String hash = "";
for(byte aux : digest)
{
int b = aux & 0xff;
if (Integer.toHexString(b).length() == 1)
{
hash += "0";
}
hash += Integer.toHexString(b);
}
oneAuth = token[0] + ":" + hash;
}
catch (FileNotFoundException e)
{
+31
View File
@@ -0,0 +1,31 @@
# -------------------------------------------------------------------------- *
# 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. *
# -------------------------------------------------------------------------- *
require "rexml/document"
include REXML
module Migrator
def db_version
"2.9.90"
end
def one_version
"OpenNebula 2.9.90"
end
def up
return true
end
end
+48
View File
@@ -0,0 +1,48 @@
# -------------------------------------------------------------------------- *
# 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. *
# -------------------------------------------------------------------------- *
require "rexml/document"
include REXML
module Migrator
def db_version
"3.0"
end
def one_version
"OpenNebula 3.0"
end
def up
# The tm_nfs driver has been renamed to tm_shared
# CREATE TABLE host_pool (oid INTEGER PRIMARY KEY, name VARCHAR(256), body TEXT, state INTEGER, last_mon_time INTEGER, UNIQUE(name));
@db.fetch("SELECT * FROM host_pool") do |row|
doc = Document.new(row[:body])
source = nil
doc.root.each_element("TM_MAD") { |e|
if e.text.downcase == "tm_nfs"
e.text = "tm_shared"
@db[:host_pool].filter(:oid => row[:oid]).update(
:body => doc.root.to_s)
end
}
end
return true
end
end
+115
View File
@@ -0,0 +1,115 @@
# -------------------------------------------------------------------------- #
# 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. #
#--------------------------------------------------------------------------- #
###############################################################################
# The Configuration Class represents a simple configuration file for the
# Cloud servers. It does not check syntax.
###############################################################################
class Configuration
###########################################################################
# Patterns to parse the Configuration File
###########################################################################
NAME_REG =/[\w\d_-]+/
VARIABLE_REG =/\s*(#{NAME_REG})\s*=\s*/
SIMPLE_VARIABLE_REG =/#{VARIABLE_REG}([^\[]+?)(#.*)?/
SINGLE_VARIABLE_REG =/^#{SIMPLE_VARIABLE_REG}$/
ARRAY_VARIABLE_REG =/^#{VARIABLE_REG}\[(.*?)\]/m
###########################################################################
###########################################################################
def initialize(file)
@conf=parse_conf(file)
end
def add_configuration_value(key,value)
add_value(@conf,key,value)
end
def [](key)
@conf[key.to_s.upcase]
end
###########################################################################
###########################################################################
private
#
#
#
def add_value(conf, key, value)
if conf[key]
if !conf[key].kind_of?(Array)
conf[key]=[conf[key]]
end
conf[key]<<value
else
conf[key]=value
end
end
#
#
#
def parse_conf(file)
conf_file=File.read(file)
conf=Hash.new
conf_file.scan(SINGLE_VARIABLE_REG) {|m|
key=m[0].strip.upcase
value=m[1].strip
# hack to skip multiline VM_TYPE values
next if %w{NAME TEMPLATE}.include? key.upcase
add_value(conf, key, value)
}
conf_file.scan(ARRAY_VARIABLE_REG) {|m|
master_key=m[0].strip.upcase
pieces=m[1].split(',')
vars=Hash.new
pieces.each {|p|
key, value=p.split('=')
vars[key.strip.upcase]=value.strip
}
add_value(conf, master_key, vars)
}
conf
end
end
#
# Test program for the Configuration Parser
#
if $0 == __FILE__
require 'pp'
conf=Configuration.new('cloud.conf')
pp conf
end
+1 -1
View File
@@ -14,7 +14,7 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
require 'cloud/Configuration'
require 'Configuration'
require 'onedb_backend'
class OneDB
@@ -29,8 +29,10 @@ module OZones
htaccess << "RewriteRule ^#{vdc.name} " +
"#{zone.endpoint} [P]\n"
if zone.sunsendpoint != nil
htaccess << "RewriteRule ^sunstone_#{vdc.name}/(.+) " +
"#{zone.sunsendpoint}/$1 [P]\n"
htaccess << "RewriteRule ^sunstone_#{vdc.name} " +
"#{zone.sunsendpoint} [P]\n"
"#{zone.sunsendpoint}/ [P]\n"
end
}
}
-2
View File
@@ -278,8 +278,6 @@ class OzonesServer
data = result if !OpenNebula.is_error?(result)
end
puts data
resource = case kind
when "vdc" then
vdc_data=Hash.new
@@ -36,7 +36,7 @@ var dashboard_tab_content =
</td>\
<td>\
<div class="panel">\
<h3><a href="#vdcs_tab">Virtual Data Center</a>\
<h3><a href="#vdcs_tab">Virtual Data Centers</a>\
<div class="new-resource">\
<a class="action_button" href="#vdcs_tab" value="VDC.create_dialog">+</a>\
</div>\
@@ -47,7 +47,7 @@ var create_vdc_tmpl =
<select id="zoneid" name="zone">\
</select><br />\
<div class="clear"></div>\
<label for="vdc_force_hosts">Host multiplacement:</label>\
<label for="vdc_force_hosts">VDC host sharing:</label>\
<input type="checkbox" name="vdc_force_hosts" id="vdc_force_hosts" />\
<div class="tip">Allows hosts belonging to other VDCs to be re-added to this one. They will appear marked with * in the list.</div>\
<div class="clear"></div>\
@@ -75,7 +75,7 @@ var update_vdc_tmpl =
<select name="vdc_update_id" id="vdc_update_id">\
</select>\
<div class="clear"></div>\
<label for="vdc_update_force_hosts">Host multiplacement:</label>\
<label for="vdc_update_force_hosts">VDC host sharing:</label>\
<input type="checkbox" name="vdc_update_force_hosts" id="vdc_update_force_hosts" />\
<div class="tip">Allows hosts belonging to other VDCs to be re-added to this one. They will appear marked with * in the list.</div>\
<div class="clear"></div>\
@@ -41,10 +41,12 @@ var create_zone_tmpl =
<input type="text" name="name" id="name" /><br />\
<label for="endpoint">End point:</label>\
<input type="text" name="endpoint" id="endpoint" /><br />\
<label for="onename">ONE auth:</label>\
<label for="onename">Oneadmin user:</label>\
<input type="text" name="onename" id="onename" /><br />\
<label for="onepass">Password:</label>\
<input type="password" name="onepass" id="onepass" />\
<label for="sunsendpoint">Sunstone end point:</label>\
<input type="text" name="sunsendpoint" id="sunsendpoint" /><br />\
</div>\
</fieldset>\
<fieldset>\
@@ -298,6 +300,10 @@ function updateZoneInfo(req,zone_json){
<td class="key_td">Endpoint</td>\
<td class="value_td">'+zone.endpoint+'</td>\
</tr>\
<tr>\
<td class="key_td">Sunstone endpoint</td>\
<td class="value_td"><a href="'+zone.sunsendpoint+'" target="_blank">'+zone.sunsendpoint+'<span class="ui-icon ui-icon-extlink" style="display:inline-block;" /></a></td>\
</tr>\
<tr>\
<td class="key_td">#VDCs</td>\
<td class="value_td">'+zone.vdcs.length+'</td>\
@@ -544,6 +550,7 @@ function setupCreateZoneDialog(){
var endpoint = $('#endpoint',this).val();
var onename = $('#onename',this).val();
var onepass = $('#onepass',this).val();
var sunsendpoint = $('#sunsendpoint',this).val();
if (!name.length || !endpoint.length ||
!onename.length || !onepass.length){
@@ -556,7 +563,8 @@ function setupCreateZoneDialog(){
"name": name,
"endpoint": endpoint,
"onename": onename,
"onepass": onepass
"onepass": onepass,
"sunsendpoint" : sunsendpoint
}
};
@@ -589,7 +597,8 @@ $(document).ready(function(){
"sPaginationType": "full_numbers",
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "60px", "aTargets": [0,2] },
{ "sWidth": "60px", "aTargets": [0] },
{ "sWidth": "300px", "aTargets": [3] },
{ "sWidth": "35px", "aTargets": [1] }
]
});
+1 -1
View File
@@ -96,7 +96,7 @@ private:
int read_oneauth(string &secret);
int split_secret(const string secret, string& user, string& pass);
int split_secret(const string& secret);
};
#endif /*ONECLIENT_H_*/
+22 -23
View File
@@ -38,9 +38,6 @@ const int Client::MESSAGE_SIZE = 51200;
void Client::set_one_auth(string secret)
{
string user = "";
string pass = "";
int rc = 0;
if( secret == "" )
@@ -50,18 +47,11 @@ void Client::set_one_auth(string secret)
if ( rc == 0 )
{
rc = split_secret(secret, user, pass);
rc = split_secret(secret);
if( rc == 0 )
if( rc != 0 )
{
string sha1_pass = SSLTools::sha1_digest(pass);
one_auth = user + ":" + sha1_pass;
}
else
{
throw runtime_error("Wrong format for auth token, must "
"be <username>:<passwd>");
throw runtime_error("Wrong format for auth token");
}
}
}
@@ -132,23 +122,32 @@ int Client::read_oneauth(string &secret)
return rc;
}
int Client::split_secret(const string secret, string& user, string& pass)
int Client::split_secret(const string& secret)
{
size_t pos;
int rc = -1;
pos=secret.find(":");
pos = secret.find(":");
if (pos != string::npos)
if ( pos == string::npos )
{
user = secret.substr(0,pos);
pass = secret.substr(pos+1);
rc = 0;
return -1;
}
return rc;
if ( secret.rfind(":") == pos )
{
string user = secret.substr(0,pos);
string pass = secret.substr(pos+1);
string sha1_pass = SSLTools::sha1_digest(pass);
one_auth = user + ":" + sha1_pass;
}
else
{
one_auth = secret;
}
return 0;
}
/* -------------------------------------------------------------------------- */
+3 -1
View File
@@ -229,7 +229,9 @@ class SunstoneServer
begin
novnc_cmd = "#{config[:novnc_path]}/utils/wsproxy.py"
pipe = IO.popen("#{novnc_cmd} #{proxy_port} #{host}:#{vnc_port}")
novnc_exec = "#{novnc_cmd} #{proxy_port} #{host}:#{vnc_port}"
$stderr.puts("Starting vnc proxy: #{novnc_exec}")
pipe = IO.popen(novnc_exec)
rescue Exception => e
error = Error.new(e.message)
return [500, error.to_json]
+8 -1
View File
@@ -16,6 +16,8 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
CONTEXT_FILE=$1
while (( "$#" )); do
if [ "$#" == "1" ]; then
DST=$1
@@ -56,7 +58,12 @@ for f in $SRC; do
;;
*)
exec_and_log "cp -R $f $ISO_DIR"
if [ $SECURE_CONTEXT -eq 0 -o "$f" == "$CONTEXT_FILE" ]; then
exec_and_log "cp -R $f $ISO_DIR" \
"Error copying $f to $ISO_DIR"
else
log "not copying potentialy dangerous file $f"
fi
;;
esac
done
+3
View File
@@ -22,6 +22,9 @@ VG_NAME=
# Default size for logical volumes if not specified
DEFAULT_LV_SIZE="1G"
# Set to 1 to disable adding files to context image other than context.sh
# itself or http url's
SECURE_CONTEXT=0
# -------------------------------------------------------------------------- #
# Helper functions for the LVM plugin #
+8 -2
View File
@@ -16,6 +16,8 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
CONTEXT_FILE=$1
while (( "$#" )); do
if [ "$#" == "1" ]; then
DST=$1
@@ -53,8 +55,12 @@ for f in $SRC; do
;;
*)
exec_and_log "cp -R $f $ISO_DIR" \
"Error copying $f to $ISO_DIR"
if [ $SECURE_CONTEXT -eq 0 -o "$f" == "$CONTEXT_FILE" ]; then
exec_and_log "cp -R $f $ISO_DIR" \
"Error copying $f to $ISO_DIR"
else
log "not copying potentialy dangerous file $f"
fi
;;
esac
done
+4
View File
@@ -13,3 +13,7 @@
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# Set to 1 to disable adding files to context image other than context.sh
# itself or http url's
SECURE_CONTEXT=0
+8 -2
View File
@@ -16,6 +16,8 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
CONTEXT_FILE=$1
while (( "$#" )); do
if [ "$#" == "1" ]; then
DST=$1
@@ -58,8 +60,12 @@ for f in $SRC; do
;;
*)
exec_and_log "cp -R $f $ISO_DIR" \
"Error copying $f to $ISO_DIR"
if [ $SECURE_CONTEXT -eq 0 -o "$f" == "$CONTEXT_FILE" ]; then
exec_and_log "cp -R $f $ISO_DIR" \
"Error copying $f to $ISO_DIR"
else
log "not copying potentialy dangerous file $f"
fi
;;
esac
done
+4
View File
@@ -13,3 +13,7 @@
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# Set to 1 to disable adding files to context image other than context.sh
# itself or http url's
SECURE_CONTEXT=0