Class: Nifty::Backends::Utils::Opennebula::DatastoreHandler

Inherits:
Handler
  • Object
show all
Defined in:
lib/nifty/backends/utils/opennebula/datastore_handler.rb

Overview

Handler for OpenNebula DatastorePool

Author:

  • Michal Kimle

Constant Summary

Constants inherited from Handler

Handler::API_POLLING_WAIT, Handler::ATTRIBUTE_APPLIANCE_ID, Handler::LEAVE_AS_IS, Handler::ONEADMIN_ID, Handler::OWNER_OCTET

Instance Attribute Summary

Attributes inherited from Handler

#client, #pool

Instance Method Summary collapse

Methods inherited from Handler

chmod, chown, #reload!

Constructor Details

#initialize(client) ⇒ DatastoreHandler

Constructor

See Also:



9
10
11
12
# File 'lib/nifty/backends/utils/opennebula/datastore_handler.rb', line 9

def initialize(client)
  super(client)
  @pool = OpenNebula::DatastorePool.new(client)
end

Instance Method Details

#datastores(names) ⇒ Array

Returns list of datastores matching the names If there is no datastore with given name, it’s skipped.

Parameters:

  • names (Array)

    array of the names

Returns:

  • (Array)

    array of found datastores



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/nifty/backends/utils/opennebula/datastore_handler.rb', line 19

def datastores(names)
  reload!

  datastores = []
  names.each do |name|
    datastore = pool.find { |ds| ds.name == name }

    unless datastore
      logger.warn("Datastore #{name.inspect} was not found, skipping.")
      next
    end

    datastores << datastore
  end

  datastores
end