1
// Copyright 2012, 2013 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
10
"launchpad.net/juju-core/errors"
11
"launchpad.net/juju-core/state"
14
// DestroyMachines1dot16 destroys the machines with the specified ids.
15
// This is copied from the 1.16.3 code to enable compatibility. It should be
16
// removed when we release a version that goes via the API only (whatever is
18
func DestroyMachines1dot16(st *state.State, ids ...string) (err error) {
20
for _, id := range ids {
21
machine, err := st.Machine(id)
23
case errors.IsNotFoundError(err):
24
err = fmt.Errorf("machine %s does not exist", id)
26
case machine.Life() != state.Alive:
29
err = machine.Destroy()
32
errs = append(errs, err.Error())
38
msg := "some machines were not destroyed"
39
if len(errs) == len(ids) {
40
msg = "no machines were destroyed"
42
return fmt.Errorf("%s: %s", msg, strings.Join(errs, "; "))