Top Level Namespace

Includes:
CloudCLI, OpenNebula

Defined Under Namespace

Modules: CloudCLI, CloudClient, ElasticityGrammar, OpenNebula, Role, Service, Validator Classes: ElasticityGrammarParser, Hash

Constant Summary collapse

ONE_LOCATION =
ENV['ONE_LOCATION']
VAR_LOCATION =
ONE_LOCATION+'/var/'

Constants included from OpenNebula

OpenNebula::DEFAULT_POOL_PAGE_SIZE, OpenNebula::VERSION

Instance Method Summary collapse

Methods included from CloudCLI

#cmd_name, #print_xml, #version_text

Methods included from OpenNebula

decrypt, encrypt, handle_driver_exception, is_error?, pool_page_size, process_monitoring

Instance Method Details

#get_server_order(opts, user) ⇒ Object



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/opennebula/ldap_auth.rb', line 259

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) ⇒ Object

—————————————————————————- # Helper functions to parse ldap_auth.conf server entries —————————————————————————- #



244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/opennebula/ldap_auth.rb', line 244

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