   findMachineFromMachineId: (machineId)->
     return @machinesById[machineId]
 
+  findStackFromStackId: (stackId)->
+    return @stacksById[stackId]
+
+  findStackFromMachineId: (machineId)->
+    for stack in @stacks
+      return stack  if machineId in stack.machines
 
   findMachineFromQueryString: (queryString)->
 

    @stacks       = []
    @machines     = []
    @machinesById = {}
    @plans        = null
    @_trials      = {}


            queue = []
            return

          @stacksById   = {}
          for stack in stacks
            @stacksById[stack._id] = stack

          @machinesById = {}

          machines = []
