Top Level Namespace

Includes:
CloudCLI, OpenNebula

Defined Under Namespace

Modules: CloudCLI, CloudClient, DriverExecHelper, ElasticityGrammar, Memoize, NSXDriver, OpenNebula, Role, Service, VCenterDriver, Validator, VirtualMachineDevice, VirtualMachineHelper, VirtualMachineMonitor Classes: ActionManager, ElasticityGrammarParser, GenericCommand, Hash, LocalCommand, OpenNebulaDriver, RemotesCommand, SSHCommand, Sample, TemplateDriver, VCenterConf, VirtualMachineDriver

Constant Summary collapse

BIN_LOCATION =
ONE_LOCATION + '/bin'
LIB_LOCATION =
ONE_LOCATION + '/lib'
ETC_LOCATION =
ONE_LOCATION + '/etc/'
VAR_LOCATION =
ONE_LOCATION+"/var/"
GEMS_LOCATION =
ONE_LOCATION + '/share/gems'
CHECK_REFS =
true
ONE_LOCATION =
ENV["ONE_LOCATION"]

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

arg_host, arg_path, decrypt, encrypt, error_message, exec_and_log, handle_driver_exception, is_disk?, is_error?, log_debug, log_error, log_function, log_info, log_warning, pool_page_size, process_monitoring, send_to_monitor

Instance Method Details

#check_item(item, target_class) ⇒ Object



143
144
145
146
147
148
149
150
151
152
# 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) ⇒ Object

—————————————————————————- # Helper functions # —————————————————————————- #



136
137
138
139
140
141
# 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) ⇒ Object



250
251
252
253
254
255
256
257
258
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
# 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) ⇒ Object

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



235
236
237
238
239
240
241
242
243
244
245
246
247
248
# 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