diff --git a/install.sh b/install.sh index cd25ed8d40..9157e15055 100755 --- a/install.sh +++ b/install.sh @@ -20,7 +20,7 @@ # Install program for OpenNebula. It will install it relative to # $ONE_LOCATION if defined with the -d option, otherwise it'll be installed # under /. In this case you may specified the oneadmin user/group, so you do -# not need run the OpenNebula daemon with root priviledges +# not need run the OpenNebula daemon with root privileges #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- @@ -300,7 +300,7 @@ elif [ "$SUNSTONE" = "yes" ]; then elif [ "$OZONES" = "yes" ]; then MAKE_DIRS="$MAKE_DIRS $OZONES_DIRS $OZONES_CLIENT_DIRS $LIB_OCA_CLIENT_DIRS" else - MAKE_DIRS="$MAKE_DIRS $SHARE_DIRS $ETC_DIRS $LIB_DIRS $VAR_DIRS \ + MAKE_DIRS="$MAKE_DIRS $SHARE_DIRS $ETC_DIRS $LIB_DIRS $VAR_DIRS \ $OZONES_DIRS $OZONES_CLIENT_DIRS $SUNSTONE_DIRS" fi @@ -655,8 +655,7 @@ ONEDB_MIGRATOR_FILES="src/onedb/2.0_to_2.9.80.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/Configuration.rb" + src/onedb/onedb_backend.rb" #------------------------------------------------------------------------------- # Configuration files for OpenNebula, to be installed under $ETC_LOCATION @@ -786,7 +785,8 @@ RUBY_OPENNEBULA_LIB_FILES="src/oca/ruby/OpenNebula/Host.rb \ src/oca/ruby/OpenNebula/GroupPool.rb \ src/oca/ruby/OpenNebula/Acl.rb \ src/oca/ruby/OpenNebula/AclPool.rb \ - src/oca/ruby/OpenNebula/XMLUtils.rb" + src/oca/ruby/OpenNebula/XMLUtils.rb \ + src/oca/ruby/OpenNebula/Configuration.rb" #------------------------------------------------------------------------------- # Common Cloud Files diff --git a/src/oca/ruby/OpenNebula/Configuration.rb b/src/oca/ruby/OpenNebula/Configuration.rb new file mode 100644 index 0000000000..fed14323b6 --- /dev/null +++ b/src/oca/ruby/OpenNebula/Configuration.rb @@ -0,0 +1,116 @@ +# -------------------------------------------------------------------------- # +# 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 'json' + +module OpenNebula + ############################################################################ + # The Configuration Class represents a simple configuration file using + # OpenNebula syntax. It does not check syntax. + ############################################################################ + class Configuration + attr_reader :conf + + ######################################################################## + # 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(str) + parse_conf(str) + end + + def self.new_from_file(file) + conf_file = File.read(file) + self.new(conf_file) + end + + def add_value(key, value) + if @conf[key] + if !@conf[key].kind_of?(Array) + @conf[key]=[@conf[key]] + end + @conf[key]< tmpl.conf } - body_str << "\n }\n" - body_str << "}\n" + return JSON::generate(res) end def self.parse_json(json_str, root_element)