~dave-cheney/juju-core/153-fix-release-tools-script

« back to all changes in this revision

Viewing changes to cmd/jujud/machine.go

  • Committer: Tarmac
  • Author(s): Andrew Wilkins
  • Date: 2013-08-30 01:48:39 UTC
  • mfrom: (1628.11.22 juju-add-machine)
  • Revision ID: tarmac-20130830014839-infsllif52ywy6yq
[r=axwalk] Update add-machine for manual provisioning

juju add-machine is updated to use a new package,
environs/manual, to manually provision tools and
a machine agent to an existing machine.

When a manually provisioned machine is destroyed
via juju destroy-machine, the machine agent will
detect its termination and remove its upstart
configuration file. There is currently no cleanup
of the data or log directories; this will be done
in a follow-up pending discussion.

When the machine goes to Dead, a provisioner will
remove the machine from state just like any other
machine.

TODO: destroy-environment will currently leak
manually provisioned machines. A follow-up will
address this by requiring users to individually
destroy-machine before destroy-environment will
proceed. Alternatively (or perhaps additionally),
destroy-environment may take a flag to automatically
do this.

https://codereview.appspot.com/12831043/

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
        "launchpad.net/juju-core/state"
24
24
        "launchpad.net/juju-core/state/api/params"
25
25
        "launchpad.net/juju-core/state/apiserver"
 
26
        "launchpad.net/juju-core/upstart"
26
27
        "launchpad.net/juju-core/worker"
27
28
        "launchpad.net/juju-core/worker/cleaner"
28
29
        "launchpad.net/juju-core/worker/firewaller"
117
118
        a.runner.StartWorker("api", func() (worker.Worker, error) {
118
119
                return a.APIWorker(ensureStateWorker)
119
120
        })
120
 
        err := agentDone(a.runner.Wait())
 
121
        err := a.runner.Wait()
 
122
        if err == worker.ErrTerminateAgent {
 
123
                err = a.uninstallAgent()
 
124
        }
 
125
        err = agentDone(err)
121
126
        a.tomb.Kill(err)
122
127
        return err
123
128
}
289
294
        return names.MachineTag(a.MachineId)
290
295
}
291
296
 
 
297
func (m *MachineAgent) uninstallAgent() error {
 
298
        // TODO(axw) get this from agent config when it's available
 
299
        name := os.Getenv("UPSTART_JOB")
 
300
        if name != "" {
 
301
                return upstart.NewService(name).Remove()
 
302
        }
 
303
        return nil
 
304
}
 
305
 
292
306
// Below pieces are used for testing,to give us access to the *State opened
293
307
// by the agent, and allow us to trigger syncs without waiting 5s for them
294
308
// to happen automatically.