Class: Chef::Knife::AcropolisTask

Inherits:
Chef::Knife show all
Includes:
AcropolisBase
Defined in:
lib/chef/knife/acropolis_task_list.rb

Instance Method Summary collapse

Methods included from AcropolisBase

#delete, #get, included, #post, #validate

Instance Method Details

#runObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/chef/knife/acropolis_task_list.rb', line 21

def run
  task_list = [
    ui.color('UUID', :bold),
    ui.color('Operation', :bold),
    ui.color('Status', :bold),
    ui.color('VM-UUID', :bold),
    ui.color('Type', :bold)
  ]
    
  if config[:completed]
    tasks = get("/tasks/?includeCompleted=true")
    info = JSON.parse(tasks)
    info["entities"].each do |task|
      task_list << task["uuid"].to_s
      task_list << task["operationType"].to_s
      task_list << task["progressStatus"].to_s
      task_list << task["entityList"][0]["uuid"]
      task_list << task["entityList"][0]["entityType"]
    end
    print ui.list(task_list, :uneven_columns_across, 5)
  else
    tasks = get("/tasks")
    info = JSON.parse(tasks)
    if info["entities"].any?
      info["entities"].each do |task|
        task_list << task["uuid"].to_s
        task_list << task["operationType"].to_s
        task_list << task["progressStatus"].to_s
        task_list << task["entityList"][0]["uuid"]
        task_list << task["entityList"][0]["entityType"]
      end
      print ui.list(task_list, :uneven_columns_across, 5)
    else
      ui.error("no actual tasks, using -C shows completed tasks")
    end
  end
end