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

« back to all changes in this revision

Viewing changes to state/api/machiner/machiner.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:
4
4
package machiner
5
5
 
6
6
import (
7
 
        "fmt"
8
 
 
 
7
        "launchpad.net/juju-core/state/api/base"
9
8
        "launchpad.net/juju-core/state/api/common"
10
9
        "launchpad.net/juju-core/state/api/params"
11
10
)
12
11
 
13
12
// State provides access to the Machiner API facade.
14
13
type State struct {
15
 
        caller common.Caller
 
14
        caller base.Caller
16
15
}
17
16
 
18
17
// NewState creates a new client-side Machiner facade.
19
 
func NewState(caller common.Caller) *State {
 
18
func NewState(caller base.Caller) *State {
20
19
        return &State{caller}
21
20
}
22
21
 
23
22
// machineLife requests the lifecycle of the given machine from the server.
24
23
func (st *State) machineLife(tag string) (params.Life, error) {
25
 
        var result params.LifeResults
26
 
        args := params.Entities{
27
 
                Entities: []params.Entity{{Tag: tag}},
28
 
        }
29
 
        err := st.caller.Call("Machiner", "", "Life", args, &result)
30
 
        if err != nil {
31
 
                return "", err
32
 
        }
33
 
        if len(result.Results) != 1 {
34
 
                return "", fmt.Errorf("expected one result, got %d", len(result.Results))
35
 
        }
36
 
        if err := result.Results[0].Error; err != nil {
37
 
                return "", err
38
 
        }
39
 
        return result.Results[0].Life, nil
 
24
        return common.Life(st.caller, "Machiner", tag)
40
25
}
41
26
 
42
27
// Machine provides access to methods of a state.Machine through the facade.