class Object
Constants
- BIN_LOCATION
- CHECK_REFS
- CURL_LOADED
- ETC_LOCATION
- GEMS_LOCATION
- LIB_LOCATION
- MULTIPART_LOADED
- ONE_LOCATION
—————————————————————————- # Set up the environment for the driver # —————————————————————————- #
- REST_CLIENT
- REXML_FORMATTERS
- VAR_LOCATION
Public Instance Methods
check_item(item, target_class)
click to toggle source
# File lib/vcenter_driver.rb, line 143 def check_item(item, target_class) item.name if CHECK_REFS if target_class && !item.instance_of?(target_class) raise "Expecting type 'RbVmomi::VIM::#{target_class}'. " \ "Got '#{item.class} instead." end rescue RbVmomi::Fault => e raise "Reference \"#{item._ref}\" error [#{e.message}]. \ The reference does not exist" end
check_valid(parameter, label)
click to toggle source
—————————————————————————- # Helper functions # —————————————————————————- #
# File lib/vcenter_driver.rb, line 136 def check_valid(parameter, label) return unless parameter.nil? || parameter.empty? STDERR.puts "The parameter '#{label}' is required for this action." exit(-1) end
get_server_order(opts, user)
click to toggle source
# File lib/opennebula/ldap_auth.rb, line 250 def get_server_order(opts, user) order = [] if opts[:order] && opts[:match_user_regex] STDERR.puts ":order and :match_user_regex are mutually exclusive" exit(-1) end if opts[:order] if opts[:order].class != Array STDERR.puts ":order value malformed, must be an Array" exit(-1) end opts[:order].each do |name| order << to_array(name) end elsif opts[:match_user_regex] if opts[:match_user_regex].class != Hash || opts[:match_user_regex].empty? STDERR.puts ":match_user_regex value malformed, must be an Hash" exit(-1) end opts[:match_user_regex].each do |regex, server| if m = user.match(/#{regex}/i) # update user with the capture user = m[1] if m[1] order << to_array(server) break end end if order.empty? STDERR.puts "User #{user} does not mach any regex" end else STDERR.puts "missing either :order or :match_user_regex in configuration" exit(-1) end return [order, user] end
to_array(name)
click to toggle source
—————————————————————————- # Helper functions to parse ldap_auth.conf server entries —————————————————————————- #
# File lib/opennebula/ldap_auth.rb, line 235 def to_array(name) if name.is_a? Array name elsif name.is_a? Hash if name.keys.size == 1 [name.values].flatten else STDERR.puts "invalid group configuration: #{name}" exit(-1) end else [name] end end