~james-page/ubuntu/wily/juju-core/mir-fixes

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/state/api/firewaller/firewaller.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-03-28 08:58:42 UTC
  • mfrom: (1.1.21)
  • Revision ID: package-import@ubuntu.com-20140328085842-cyzrgc120bdfxwj0
Tags: 1.17.7-0ubuntu1
* New upstream point release, including fixes for:
  - no debug log with all providers on Ubuntu 14.04 (LP: #1294776).
* d/control: Add cpu-checker dependency to juju-local (LP: #1297077).

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
package firewaller
5
5
 
6
6
import (
7
 
        "launchpad.net/juju-core/environs/config"
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
        "launchpad.net/juju-core/state/api/watcher"
12
11
)
13
12
 
 
13
const firewallerFacade = "Firewaller"
 
14
 
14
15
// State provides access to the Firewaller API facade.
15
16
type State struct {
16
17
        caller base.Caller
 
18
        *common.EnvironWatcher
 
19
}
 
20
 
 
21
func (st *State) call(method string, params, result interface{}) error {
 
22
        return st.caller.Call(firewallerFacade, "", method, params, result)
17
23
}
18
24
 
19
25
// NewState creates a new client-side Firewaller facade.
20
26
func NewState(caller base.Caller) *State {
21
 
        return &State{caller}
 
27
        return &State{
 
28
                caller:         caller,
 
29
                EnvironWatcher: common.NewEnvironWatcher(firewallerFacade, caller),
 
30
        }
22
31
}
23
32
 
24
33
// life requests the life cycle of the given entity from the server.
25
34
func (st *State) life(tag string) (params.Life, error) {
26
 
        return common.Life(st.caller, "Firewaller", tag)
 
35
        return common.Life(st.caller, firewallerFacade, tag)
27
36
}
28
37
 
29
38
// Unit provides access to methods of a state.Unit through the facade.
53
62
        }, nil
54
63
}
55
64
 
56
 
// WatchForEnvironConfigChanges return a NotifyWatcher waiting for the
57
 
// environment configuration to change.
58
 
func (st *State) WatchForEnvironConfigChanges() (watcher.NotifyWatcher, error) {
59
 
        var result params.NotifyWatchResult
60
 
        err := st.caller.Call("Firewaller", "", "WatchForEnvironConfigChanges", nil, &result)
61
 
        if err != nil {
62
 
                return nil, err
63
 
        }
64
 
        if err := result.Error; err != nil {
65
 
                return nil, result.Error
66
 
        }
67
 
        w := watcher.NewNotifyWatcher(st.caller, result)
68
 
        return w, nil
69
 
}
70
 
 
71
 
// EnvironConfig returns the current environment configuration.
72
 
func (st *State) EnvironConfig() (*config.Config, error) {
73
 
        var result params.EnvironConfigResult
74
 
        err := st.caller.Call("Firewaller", "", "EnvironConfig", nil, &result)
75
 
        if err != nil {
76
 
                return nil, err
77
 
        }
78
 
        if err := result.Error; err != nil {
79
 
                return nil, err
80
 
        }
81
 
        conf, err := config.New(config.NoDefaults, result.Config)
82
 
        if err != nil {
83
 
                return nil, err
84
 
        }
85
 
        return conf, nil
86
 
}
87
 
 
88
65
// WatchEnvironMachines returns a StringsWatcher that notifies of
89
66
// changes to the life cycles of the top level machines in the current
90
67
// environment.
91
68
func (st *State) WatchEnvironMachines() (watcher.StringsWatcher, error) {
92
69
        var result params.StringsWatchResult
93
 
        err := st.caller.Call("Firewaller", "", "WatchEnvironMachines", nil, &result)
 
70
        err := st.call("WatchEnvironMachines", nil, &result)
94
71
        if err != nil {
95
72
                return nil, err
96
73
        }