~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cmd/jujud/agent/machine/manifolds.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
package machine
5
5
 
6
6
import (
 
7
        "github.com/juju/utils/voyeur"
 
8
 
7
9
        coreagent "github.com/juju/juju/agent"
8
10
        "github.com/juju/juju/api"
9
11
        apideployer "github.com/juju/juju/api/deployer"
10
12
        "github.com/juju/juju/state"
11
 
        "github.com/juju/juju/version"
12
13
        "github.com/juju/juju/worker"
13
14
        "github.com/juju/juju/worker/agent"
14
15
        "github.com/juju/juju/worker/apiaddressupdater"
25
26
        "github.com/juju/juju/worker/proxyupdater"
26
27
        "github.com/juju/juju/worker/reboot"
27
28
        "github.com/juju/juju/worker/resumer"
 
29
        workerstate "github.com/juju/juju/worker/state"
 
30
        "github.com/juju/juju/worker/stateconfigwatcher"
28
31
        "github.com/juju/juju/worker/storageprovisioner"
29
32
        "github.com/juju/juju/worker/terminationworker"
 
33
        "github.com/juju/juju/worker/toolsversionchecker"
30
34
        "github.com/juju/juju/worker/upgrader"
31
35
        "github.com/juju/juju/worker/upgradesteps"
32
36
        "github.com/juju/juju/worker/upgradewaiter"
33
37
        "github.com/juju/juju/worker/util"
34
38
        "github.com/juju/utils/clock"
 
39
        "github.com/juju/version"
35
40
)
36
41
 
37
42
// ManifoldsConfig allows specialisation of the result of Manifolds.
40
45
        // its dependencies via a dependency.Engine.
41
46
        Agent coreagent.Agent
42
47
 
 
48
        // AgentConfigChanged is set whenever the machine agent's config
 
49
        // is updated.
 
50
        AgentConfigChanged *voyeur.Value
 
51
 
43
52
        // PreviousAgentVersion passes through the version the machine
44
53
        // agent was running before the current restart.
45
54
        PreviousAgentVersion version.Number
54
63
        // upgrader worker completes it's first check.
55
64
        UpgradeCheckLock gate.Lock
56
65
 
 
66
        // OpenState is function used by the state manifold to create a
 
67
        // *state.State.
 
68
        OpenState func(coreagent.Config) (*state.State, error)
 
69
 
57
70
        // OpenStateForUpgrade is a function the upgradesteps worker can
58
71
        // use to establish a connection to state.
59
 
        OpenStateForUpgrade func() (*state.State, func(), error)
 
72
        OpenStateForUpgrade func() (*state.State, error)
 
73
 
 
74
        // StartStateWorkers is function called by the stateworkers
 
75
        // manifold to start workers which rely on a *state.State but
 
76
        // which haven't been converted to run directly under the
 
77
        // dependency engine yet. This will go once these workers have
 
78
        // been converted.
 
79
        StartStateWorkers func(*state.State) (worker.Worker, error)
60
80
 
61
81
        // WriteUninstallFile is a function the uninstaller manifold uses
62
82
        // to write the agent uninstall file.
103
123
                // returns.
104
124
                terminationName: terminationworker.Manifold(),
105
125
 
 
126
                // The stateconfigwatcher manifold watches the machine agent's
 
127
                // configuration and reports if state serving info is
 
128
                // present. It will bounce itself if state serving info is
 
129
                // added or removed. It is intended as a dependency just for
 
130
                // the state manifold.
 
131
                stateConfigWatcherName: stateconfigwatcher.Manifold(stateconfigwatcher.ManifoldConfig{
 
132
                        AgentName:          agentName,
 
133
                        AgentConfigChanged: config.AgentConfigChanged,
 
134
                }),
 
135
 
 
136
                // The state manifold creates a *state.State and makes it
 
137
                // available to other manifolds. It pings the mongodb session
 
138
                // regularly and will die if pings fail.
 
139
                stateName: workerstate.Manifold(workerstate.ManifoldConfig{
 
140
                        AgentName:              agentName,
 
141
                        StateConfigWatcherName: stateConfigWatcherName,
 
142
                        OpenState:              config.OpenState,
 
143
                }),
 
144
 
 
145
                // The stateworkers manifold starts workers which rely on a
 
146
                // *state.State but which haven't been converted to run
 
147
                // directly under the dependency engine yet. This manifold
 
148
                // will be removed once all such workers have been converted.
 
149
                stateWorkersName: StateWorkersManifold(StateWorkersConfig{
 
150
                        StateName:         stateName,
 
151
                        StartStateWorkers: config.StartStateWorkers,
 
152
                }),
 
153
 
106
154
                // The api caller is a thin concurrent wrapper around a connection
107
155
                // to some API server. It's used by many other manifolds, which all
108
156
                // select their own desired facades. It will be interesting to see
297
345
                        APICallerName:     apiCallerName,
298
346
                        UpgradeWaiterName: upgradeWaiterName,
299
347
                }),
 
348
 
 
349
                toolsversioncheckerName: toolsversionchecker.Manifold(toolsversionchecker.ManifoldConfig{
 
350
                        AgentName:         agentName,
 
351
                        APICallerName:     apiCallerName,
 
352
                        UpgradeWaiterName: upgradeWaiterName,
 
353
                }),
300
354
        }
301
355
}
302
356
 
303
357
const (
304
358
        agentName                = "agent"
305
359
        terminationName          = "termination"
 
360
        stateConfigWatcherName   = "state-config-watcher"
 
361
        stateName                = "state"
 
362
        stateWorkersName         = "stateworkers"
306
363
        apiCallerName            = "api-caller"
307
 
        apiInfoGateName          = "api-info-gate"
308
364
        upgradeStepsGateName     = "upgrade-steps-gate"
309
365
        upgradeCheckGateName     = "upgrade-check-gate"
310
366
        upgraderName             = "upgrader"
325
381
        storageprovisionerName   = "storage-provisioner-machine"
326
382
        resumerName              = "resumer"
327
383
        identityFileWriterName   = "identity-file-writer"
 
384
        toolsversioncheckerName  = "tools-version-checker"
328
385
)