Module: Cloudkeeper::One::ApplianceActions::List

Included in:
CoreConnector
Defined in:
lib/cloudkeeper/one/appliance_actions/list.rb

Instance Method Summary collapse

Instance Method Details

#list_appliances(image_list_id) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cloudkeeper/one/appliance_actions/list.rb', line 20

def list_appliances(image_list_id)
  logger.debug "Listing appliances with image list id #{image_list_id.inspect}"
  templates = template_handler.find_by_image_list_id image_list_id
  templates.uniq! { |template| template["TEMPLATE/#{Cloudkeeper::One::Opennebula::Tags::APPLIANCE_ID}"] }

  appliances = templates.map do |template|
    image = find_image_for_template template
    populate_proto_appliance template, image
  end

  logger.debug "Appliances: #{appliances.map(&:identifier).inspect}"
  appliances
end

#list_image_listsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cloudkeeper/one/appliance_actions/list.rb', line 5

def list_image_lists
  logger.debug 'Listing all image lists available in OpenNebula'
  image_list_identifiers = template_handler.find_all.map do |template|
    image_list_identifier = template["TEMPLATE/#{Cloudkeeper::One::Opennebula::Tags::APPLIANCE_IMAGE_LIST_ID}"]
    unless image_list_identifier
      logger.warn "Managed template #{template.id.inspect} is missing image list identifier"
      next
    end
    image_list_identifier
  end.compact.uniq.sort

  logger.debug "Image lists available in OpenNebula: #{image_list_identifiers.inspect}"
  image_list_identifiers.map { |ili| CloudkeeperGrpc::ImageListIdentifier.new image_list_identifier: ili }
end