Class: Chef::Knife::Cloud::VraCatalogList

Inherits:
ResourceListCommand
  • Object
show all
Includes:
VraServiceOptions
Defined in:
lib/chef/knife/vra_catalog_list.rb

Instance Method Summary collapse

Methods included from VraServiceOptions

included

Instance Method Details

#before_exec_commandObject


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/chef/knife/vra_catalog_list.rb', line 45

def before_exec_command
  @columns_with_info = [
    { label: "Catalog ID",  key: "id" },
    { label: "Name",        key: "name" },
    { label: "Description", key: "description" },
    { label: "Status",      key: "status", value_callback: method(:format_status_value) },
    { label: "Subtenant",   key: "subtenant_name" },
  ]

  @sort_by_field = "name"
end

#format_status_value(status) ⇒ Object


61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/chef/knife/vra_catalog_list.rb', line 61

def format_status_value(status)
  return "-" if status.nil?

  status = status.downcase
  color  = if status == "published"
             :green
           else
             :red
           end

  ui.color(status, color)
end

#query_resourceObject


57
58
59
# File 'lib/chef/knife/vra_catalog_list.rb', line 57

def query_resource
  @service.list_catalog_items(config[:entitled])
end