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

Merge branch 'master' into feature-789

This commit is contained in:
Ruben S. Montero 2011-09-25 03:33:32 +02:00
commit 0d42887ca6
7 changed files with 6 additions and 155 deletions

View File

@ -791,8 +791,7 @@ RUBY_OPENNEBULA_LIB_FILES="src/oca/ruby/OpenNebula/Host.rb \
COMMON_CLOUD_LIB_FILES="src/cloud/common/CloudServer.rb \
src/cloud/common/CloudClient.rb \
src/cloud/common/CloudAuth.rb
src/cloud/common/Configuration.rb"
src/cloud/common/CloudAuth.rb"
COMMON_CLOUD_CLIENT_LIB_FILES="src/cloud/common/CloudClient.rb"

View File

@ -1,115 +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. #
#--------------------------------------------------------------------------- #
###############################################################################
# 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

View File

@ -1,35 +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. #
#--------------------------------------------------------------------------- #
# OpenNebula administrator user
USER = oneadmin
PASSWORD = oneadmin
# OpenNebula sever contact information
ONE_XMLRPC=http://localhost:2633/RPC2
# Host and port where econe server will run
SERVER = localhost
PORT = 4567
# Configuration for the image repository
DATABASE = /images/var/econe.db
IMAGE_DIR = /images/tmp
#
# VM types allowed and its template file (inside templates directory)
#
VM_TYPE=[NAME=m1.small, TEMPLATE=m1.small.erb]

View File

@ -40,9 +40,9 @@ $: << RUBY_LIB_LOCATION+"/cloud/econe"
###############################################################################
require 'rubygems'
require 'sinatra'
require 'yaml'
require 'EC2QueryServer'
require 'Configuration'
include OpenNebula

View File

@ -43,6 +43,7 @@ $: << RUBY_LIB_LOCATION+"/cloud" # For the Repository Manager
################################################
require 'rubygems'
require 'sinatra'
require 'yaml'
require 'OCCIServer'

View File

@ -408,7 +408,7 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
// ------------------ Template for the new image ------------------
oss << "NAME= " << img_name << endl;
oss << "NAME= \"" << img_name << "\"" << endl;
oss << "PUBLIC = NO " << endl;
oss << "SOURCE = - " << endl;

View File

@ -45,6 +45,7 @@ $: << SUNSTONE_ROOT_DIR+'/models'
require 'rubygems'
require 'sinatra'
require 'erb'
require 'yaml'
require 'CloudAuth'
require 'SunstoneServer'
@ -166,7 +167,7 @@ end
get '/login' do
if !authorized?
templ = settings.confing[:auth]=="basic"? "login.html" : "login_x509.html"
templ = settings.config[:auth]=="basic"? "login.html" : "login_x509.html"
return File.read(File.dirname(__FILE__)+'/templates/'+templ)
end
end