~rogpeppe/juju-core/themue-058-debug-log-api

« back to all changes in this revision

Viewing changes to provider/local/environ.go

  • Committer: Frank Mueller
  • Date: 2014-01-23 14:14:49 UTC
  • mfrom: (2152.1.95 juju-core)
  • Revision ID: frank.mueller@canonical.com-20140123141449-b30l57y7gs3wjkpw
debugger: merged trunk and fixed permission and interface problems

Show diffs side-by-side

added added

removed removed

Lines of Context:
325
325
 
326
326
// Instances is specified in the Environ interface.
327
327
func (env *localEnviron) Instances(ids []instance.Id) ([]instance.Instance, error) {
328
 
        // NOTE: do we actually care about checking the existance of the instances?
329
 
        // I posit that here we don't really care, and that we are only called with
330
 
        // instance ids that we know exist.
331
328
        if len(ids) == 0 {
332
329
                return nil, nil
333
330
        }
334
 
        insts := make([]instance.Instance, len(ids))
 
331
        insts, err := env.AllInstances()
 
332
        if err != nil {
 
333
                return nil, err
 
334
        }
 
335
        allInstances := make(map[instance.Id]instance.Instance)
 
336
        for _, inst := range insts {
 
337
                allInstances[inst.Id()] = inst
 
338
        }
 
339
        var found int
 
340
        insts = make([]instance.Instance, len(ids))
335
341
        for i, id := range ids {
336
 
                insts[i] = &localInstance{id, env}
337
 
        }
338
 
        return insts, nil
 
342
                if inst, ok := allInstances[id]; ok {
 
343
                        insts[i] = inst
 
344
                        found++
 
345
                }
 
346
        }
 
347
        if found == 0 {
 
348
                insts, err = nil, environs.ErrNoInstances
 
349
        } else if found < len(ids) {
 
350
                err = environs.ErrPartialInstances
 
351
        } else {
 
352
                err = nil
 
353
        }
 
354
        return insts, err
339
355
}
340
356
 
341
357
// AllInstances is specified in the InstanceBroker interface.