Merge branch 'master' into 9318-dashboard-uses-work-units
[arvados.git] / apps / workbench / app / models / container_work_unit.rb
1 class ContainerWorkUnit < ProxyWorkUnit
2   def children
3     return self.my_children if self.my_children
4
5     items = []
6
7     crs = {}
8     reqs = ContainerRequest.where(requesting_container_uuid: uuid).results
9     reqs.each { |cr| crs[cr.container_uuid] = cr.name }
10
11     containers = Container.where(uuid: crs.keys).results
12     containers.each do |c|
13       items << c.work_unit(crs[c.uuid])
14     end
15
16     self.my_children = items
17   end
18
19   def docker_image
20     get(:container_image)
21   end
22
23   def runtime_constraints
24     get(:runtime_constraints)
25   end
26
27   def priority
28     get(:priority)
29   end
30
31   def log_collection
32     get(:log)
33   end
34
35   def outputs
36     items = []
37     items << get(:output) if get(:output)
38     items
39   end
40
41   def uri
42     uuid = get(:uuid)
43     "/containers/#{uuid}"
44   end
45
46   def title
47     "container"
48   end
49
50   def can_cancel?
51     true
52   end
53 end