Class: Chef::Knife::Cloud::OpenstackImageList

Inherits:
ResourceListCommand
  • Object
show all
Includes:
OpenstackHelpers, OpenstackServiceOptions
Defined in:
lib/chef/knife/openstack_image_list.rb

Instance Method Summary collapse

Methods included from OpenstackServiceOptions

included

Methods included from OpenstackHelpers

#create_service_instance, #instance_addresses, #primary_network_ip_address, #primary_private_ip_address, #primary_public_ip_address, #validate!

Instance Method Details

#before_exec_commandObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/chef/knife/openstack_image_list.rb', line 38

def before_exec_command
  # set resource_filters
  unless config[:disable_filter]
    @resource_filters = [{ attribute: "name", regex: /initrd$|kernel$|loader$|virtual$|vmlinuz$/ }]
  end
  # set columns_with_info map
  @columns_with_info = [
    { label: "Name", key: "name" },
    { label: "ID", key: "id" },
    { label: "Snapshot", key: "metadata", value_callback: method(:is_image_snapshot) },
  ]
  @sort_by_field = "name"
end

#is_image_snapshot(metadata) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/chef/knife/openstack_image_list.rb', line 56

def is_image_snapshot()
  snapshot = "no"
  .each do |datum|
    if (datum.key == "image_type") && (datum.value == "snapshot")
      snapshot = "yes"
    end
  end
  snapshot
end

#query_resourceObject



52
53
54
# File 'lib/chef/knife/openstack_image_list.rb', line 52

def query_resource
  @service.list_images
end