class Chef::Knife::Cloud::OpenstackImageList

Public Instance Methods

before_exec_command() click to toggle source
# 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) click to toggle source
# File lib/chef/knife/openstack_image_list.rb, line 56
def is_image_snapshot(metadata)
  snapshot = "no"
  metadata.each do |datum|
    if (datum.key == "image_type") && (datum.value == "snapshot")
      snapshot = "yes"
    end
  end
  snapshot
end
query_resource() click to toggle source
# File lib/chef/knife/openstack_image_list.rb, line 52
def query_resource
  @service.list_images
end