~mfoord/juju-core/tests-replset

« back to all changes in this revision

Viewing changes to cmd/juju/destroyunit.go

  • Committer: Benji York
  • Date: 2013-03-15 15:20:42 UTC
  • mfrom: (993.3.9 1130151)
  • Revision ID: benji.york@canonical.com-20130315152042-kn87kj7tqtkqozuq
Add ServiceDestroyUnits to the API

R=fwereade, dimitern, rog
CC=
https://codereview.appspot.com/7554046

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
        "launchpad.net/juju-core/cmd"
7
7
        "launchpad.net/juju-core/juju"
8
8
        "launchpad.net/juju-core/state"
 
9
        "launchpad.net/juju-core/state/api/params"
 
10
        "launchpad.net/juju-core/state/statecmd"
9
11
)
10
12
 
11
13
// DestroyUnitCommand is responsible for destroying service units.
36
38
        return nil
37
39
}
38
40
 
39
 
// Run connects to the environment specified on the command line
40
 
// and calls conn.DestroyUnits.
 
41
// Run connects to the environment specified on the command line and destroys
 
42
// units therein.
41
43
func (c *DestroyUnitCommand) Run(_ *cmd.Context) (err error) {
42
44
        conn, err := juju.NewConnFromName(c.EnvName)
43
45
        if err != nil {
44
46
                return err
45
47
        }
46
48
        defer conn.Close()
47
 
        return conn.DestroyUnits(c.UnitNames...)
 
49
        params := params.DestroyServiceUnits{
 
50
                UnitNames: c.UnitNames,
 
51
        }
 
52
        return statecmd.DestroyServiceUnits(conn.State, params)
48
53
}