Merge lp:~thumper/juju-core/machine-agent-environment into lp:~go-bot/juju-core/trunk

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 1574
Proposed branch: lp:~thumper/juju-core/machine-agent-environment
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 583 lines (+142/-75)
19 files modified
cmd/juju/cmd_test.go (+6/-5)
cmd/juju/deploy.go (+2/-1)
cmd/juju/environmentcommand.go (+2/-1)
cmd/juju/environmentcommand_test.go (+4/-2)
cmd/juju/main_test.go (+10/-7)
cmd/jujud/machine.go (+2/-1)
cmd/jujud/upgradevalidation.go (+2/-1)
environs/azure/customdata_test.go (+0/-1)
environs/cloudinit.go (+5/-1)
environs/cloudinit/cloudinit.go (+4/-6)
environs/cloudinit/cloudinit_test.go (+24/-23)
environs/cloudinit_test.go (+11/-10)
environs/local/environ.go (+11/-7)
environs/local/storage/worker.go (+5/-4)
juju/osenv/package_test.go (+14/-0)
juju/osenv/vars.go (+16/-0)
juju/osenv/vars_test.go (+20/-0)
upstart/service.go (+2/-4)
worker/deployer/simple.go (+2/-1)
To merge this branch: bzr merge lp:~thumper/juju-core/machine-agent-environment
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+177707@code.launchpad.net

Commit message

Use a map to store machine environment in config.

The MachineConfig now uses a map to store the environment
for the machine agent.

https://codereview.appspot.com/12005048/

Description of the change

Use a map to store machine environment in config.

The MachineConfig now uses a map to store the environment
for the machine agent.

https://codereview.appspot.com/12005048/

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Reviewers: mp+177707_code.launchpad.net,

Message:
Please take a look.

Description:
Use a map to store machine environment in config.

The MachineConfig now uses a map to store the environment
for the machine agent.

https://code.launchpad.net/~thumper/juju-core/machine-agent-environment/+merge/177707

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/12005048/

Affected files:
   A [revision details]
   M environs/azure/customdata_test.go
   M environs/cloudinit.go
   M environs/cloudinit/cloudinit.go
   M environs/cloudinit/cloudinit_test.go
   M environs/cloudinit_test.go
   M environs/local/environ.go
   M upstart/service.go

Revision history for this message
Ian Booth (wallyworld) wrote :

LGTM with the cloudinit/cloudinit fix

https://codereview.appspot.com/12005048/diff/1/environs/cloudinit.go
File environs/cloudinit.go (right):

https://codereview.appspot.com/12005048/diff/1/environs/cloudinit.go#newcode75
environs/cloudinit.go:75: mcfg.MachineEnvironment["JUJU_PROVIDER_TYPE"]
= cfg.Type()
JUJU_PROVIDER_TYPE should be a const somewhere since it's used in a few
places

https://codereview.appspot.com/12005048/diff/1/environs/cloudinit/cloudinit.go
File environs/cloudinit/cloudinit.go (left):

https://codereview.appspot.com/12005048/diff/1/environs/cloudinit/cloudinit.go#oldcode403
environs/cloudinit/cloudinit.go:403: if cfg.StateServer {
Shouldn't we look in the map to ensure the provider type is set?

https://codereview.appspot.com/12005048/

Revision history for this message
Tim Penhey (thumper) wrote :

https://codereview.appspot.com/12005048/diff/1/environs/cloudinit.go
File environs/cloudinit.go (right):

https://codereview.appspot.com/12005048/diff/1/environs/cloudinit.go#newcode75
environs/cloudinit.go:75: mcfg.MachineEnvironment["JUJU_PROVIDER_TYPE"]
= cfg.Type()
On 2013/07/31 03:32:27, wallyworld wrote:
> JUJU_PROVIDER_TYPE should be a const somewhere since it's used in a
few places

Yes, I have been thinking about this for a while. Might as well do it
now.

https://codereview.appspot.com/12005048/diff/1/environs/cloudinit/cloudinit.go
File environs/cloudinit/cloudinit.go (left):

https://codereview.appspot.com/12005048/diff/1/environs/cloudinit/cloudinit.go#oldcode403
environs/cloudinit/cloudinit.go:403: if cfg.StateServer {
On 2013/07/31 03:32:27, wallyworld wrote:
> Shouldn't we look in the map to ensure the provider type is set?

It doesn't make it invalid like the others. So, in this case, no I
don't think so.

I felt a little uneasy making the change before that put it in there.

https://codereview.appspot.com/12005048/

Revision history for this message
Tim Penhey (thumper) wrote :
Revision history for this message
Tim Penhey (thumper) wrote :

On 2013/07/31 05:14:16, thumper wrote:
> Please take a look.

I started updating some of the call sites to use the new osenv
constants, but realised there were LOTS, so stopped.

https://codereview.appspot.com/12005048/

Revision history for this message
Tim Penhey (thumper) wrote :
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

LGTM, except you have conflicts. Silly ones, from the looks of it:
mostly imports, but also a case where a function gained or lost an error
return.

I was expecting to see changes to more providers' tests. Don't those
need to set the provider type in various places as well?

https://codereview.appspot.com/12005048/

Revision history for this message
Tim Penhey (thumper) wrote :

On 2013/07/31 06:26:34, jtv.canonical wrote:
> LGTM, except you have conflicts. Silly ones, from the looks of it:
mostly
> imports, but also a case where a function gained or lost an error
return.

> I was expecting to see changes to more providers' tests. Don't those
need to
> set the provider type in various places as well?

It is handled by the generic environs function FinishMachineConfig.

https://codereview.appspot.com/12005048/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmd/juju/cmd_test.go'
--- cmd/juju/cmd_test.go 2013-07-11 03:25:06 +0000
+++ cmd/juju/cmd_test.go 2013-07-31 21:52:25 +0000
@@ -10,6 +10,7 @@
10 . "launchpad.net/gocheck"10 . "launchpad.net/gocheck"
11 "launchpad.net/juju-core/cmd"11 "launchpad.net/juju-core/cmd"
12 "launchpad.net/juju-core/environs/dummy"12 "launchpad.net/juju-core/environs/dummy"
13 "launchpad.net/juju-core/juju/osenv"
13 "launchpad.net/juju-core/juju/testing"14 "launchpad.net/juju-core/juju/testing"
14 coretesting "launchpad.net/juju-core/testing"15 coretesting "launchpad.net/juju-core/testing"
15 "launchpad.net/juju-core/testing/checkers"16 "launchpad.net/juju-core/testing/checkers"
@@ -106,10 +107,10 @@
106107
107 // JUJU_ENV is the final place the environment can be overriden108 // JUJU_ENV is the final place the environment can be overriden
108 com, args = cmdFunc()109 com, args = cmdFunc()
109 oldenv := os.Getenv("JUJU_ENV")110 oldenv := os.Getenv(osenv.JujuEnv)
110 os.Setenv("JUJU_ENV", "walthamstow")111 os.Setenv(osenv.JujuEnv, "walthamstow")
111 testInit(c, com, args, "")112 testInit(c, com, args, "")
112 os.Setenv("JUJU_ENV", oldenv)113 os.Setenv(osenv.JujuEnv, oldenv)
113 assertConnName(c, com, "walthamstow")114 assertConnName(c, com, "walthamstow")
114115
115 com, args = cmdFunc()116 com, args = cmdFunc()
@@ -196,8 +197,8 @@
196}197}
197198
198func (*CmdSuite) TestDeployCommandInit(c *C) {199func (*CmdSuite) TestDeployCommandInit(c *C) {
199 defer os.Setenv("JUJU_REPOSITORY", os.Getenv("JUJU_REPOSITORY"))200 defer os.Setenv(osenv.JujuRepository, os.Getenv(osenv.JujuRepository))
200 os.Setenv("JUJU_REPOSITORY", "/path/to/repo")201 os.Setenv(osenv.JujuRepository, "/path/to/repo")
201202
202 for _, t := range deployTests {203 for _, t := range deployTests {
203 initExpectations(t.com)204 initExpectations(t.com)
204205
=== modified file 'cmd/juju/deploy.go'
--- cmd/juju/deploy.go 2013-07-30 14:00:53 +0000
+++ cmd/juju/deploy.go 2013-07-31 21:52:25 +0000
@@ -14,6 +14,7 @@
14 "launchpad.net/juju-core/cmd"14 "launchpad.net/juju-core/cmd"
15 "launchpad.net/juju-core/constraints"15 "launchpad.net/juju-core/constraints"
16 "launchpad.net/juju-core/juju"16 "launchpad.net/juju-core/juju"
17 "launchpad.net/juju-core/juju/osenv"
17 "launchpad.net/juju-core/names"18 "launchpad.net/juju-core/names"
18)19)
1920
@@ -72,7 +73,7 @@
72 f.BoolVar(&c.BumpRevision, "upgrade", false, "")73 f.BoolVar(&c.BumpRevision, "upgrade", false, "")
73 f.Var(&c.Config, "config", "path to yaml-formatted service config")74 f.Var(&c.Config, "config", "path to yaml-formatted service config")
74 f.Var(constraints.ConstraintsValue{&c.Constraints}, "constraints", "set service constraints")75 f.Var(constraints.ConstraintsValue{&c.Constraints}, "constraints", "set service constraints")
75 f.StringVar(&c.RepoPath, "repository", os.Getenv("JUJU_REPOSITORY"), "local charm repository")76 f.StringVar(&c.RepoPath, "repository", os.Getenv(osenv.JujuRepository), "local charm repository")
76}77}
7778
78func (c *DeployCommand) Init(args []string) error {79func (c *DeployCommand) Init(args []string) error {
7980
=== modified file 'cmd/juju/environmentcommand.go'
--- cmd/juju/environmentcommand.go 2013-05-10 20:55:57 +0000
+++ cmd/juju/environmentcommand.go 2013-07-31 21:52:25 +0000
@@ -13,6 +13,7 @@
13 "launchpad.net/gnuflag"13 "launchpad.net/gnuflag"
14 "launchpad.net/juju-core/cmd"14 "launchpad.net/juju-core/cmd"
15 "launchpad.net/juju-core/environs/config"15 "launchpad.net/juju-core/environs/config"
16 "launchpad.net/juju-core/juju/osenv"
16)17)
1718
18const CurrentEnvironmentFilename = "current-environment"19const CurrentEnvironmentFilename = "current-environment"
@@ -55,7 +56,7 @@
55// JUJU_ENV environment variable. If that is set, it gets used. If it isn't56// JUJU_ENV environment variable. If that is set, it gets used. If it isn't
56// set, look in the $JUJU_HOME/current-environment file.57// set, look in the $JUJU_HOME/current-environment file.
57func getDefaultEnvironment() string {58func getDefaultEnvironment() string {
58 defaultEnv := os.Getenv("JUJU_ENV")59 defaultEnv := os.Getenv(osenv.JujuEnv)
59 if defaultEnv != "" {60 if defaultEnv != "" {
60 return defaultEnv61 return defaultEnv
61 }62 }
6263
=== modified file 'cmd/juju/environmentcommand_test.go'
--- cmd/juju/environmentcommand_test.go 2013-05-10 20:55:57 +0000
+++ cmd/juju/environmentcommand_test.go 2013-07-31 21:52:25 +0000
@@ -8,6 +8,8 @@
8 "os"8 "os"
99
10 . "launchpad.net/gocheck"10 . "launchpad.net/gocheck"
11
12 "launchpad.net/juju-core/juju/osenv"
11 "launchpad.net/juju-core/testing"13 "launchpad.net/juju-core/testing"
12)14)
1315
@@ -50,13 +52,13 @@
50}52}
5153
52func (s *EnvironmentCommandSuite) TestGetDefaultEnvironmentJujuEnvSet(c *C) {54func (s *EnvironmentCommandSuite) TestGetDefaultEnvironmentJujuEnvSet(c *C) {
53 os.Setenv("JUJU_ENV", "magic")55 os.Setenv(osenv.JujuEnv, "magic")
54 env := getDefaultEnvironment()56 env := getDefaultEnvironment()
55 c.Assert(env, Equals, "magic")57 c.Assert(env, Equals, "magic")
56}58}
5759
58func (s *EnvironmentCommandSuite) TestGetDefaultEnvironmentBothSet(c *C) {60func (s *EnvironmentCommandSuite) TestGetDefaultEnvironmentBothSet(c *C) {
59 os.Setenv("JUJU_ENV", "magic")61 os.Setenv(osenv.JujuEnv, "magic")
60 err := writeCurrentEnvironment("fubar")62 err := writeCurrentEnvironment("fubar")
61 c.Assert(err, IsNil)63 c.Assert(err, IsNil)
62 env := getDefaultEnvironment()64 env := getDefaultEnvironment()
6365
=== modified file 'cmd/juju/main_test.go'
--- cmd/juju/main_test.go 2013-07-26 00:58:46 +0000
+++ cmd/juju/main_test.go 2013-07-31 21:52:25 +0000
@@ -8,19 +8,22 @@
8 "flag"8 "flag"
9 "fmt"9 "fmt"
10 "io/ioutil"10 "io/ioutil"
11 "os"
12 "os/exec"
13 "path/filepath"
14 "strings"
15 stdtesting "testing"
16
11 "launchpad.net/gnuflag"17 "launchpad.net/gnuflag"
12 . "launchpad.net/gocheck"18 . "launchpad.net/gocheck"
19 "launchpad.net/loggo"
20
13 "launchpad.net/juju-core/cmd"21 "launchpad.net/juju-core/cmd"
14 "launchpad.net/juju-core/environs/config"22 "launchpad.net/juju-core/environs/config"
15 _ "launchpad.net/juju-core/environs/dummy"23 _ "launchpad.net/juju-core/environs/dummy"
24 "launchpad.net/juju-core/juju/osenv"
16 "launchpad.net/juju-core/testing"25 "launchpad.net/juju-core/testing"
17 "launchpad.net/juju-core/version"26 "launchpad.net/juju-core/version"
18 "launchpad.net/loggo"
19 "os"
20 "os/exec"
21 "path/filepath"
22 "strings"
23 stdtesting "testing"
24)27)
2528
26func TestPackage(t *stdtesting.T) {29func TestPackage(t *stdtesting.T) {
@@ -46,7 +49,7 @@
46func badrun(c *C, exit int, args ...string) string {49func badrun(c *C, exit int, args ...string) string {
47 localArgs := append([]string{"-test.run", "TestRunMain", "-run-main", "--", "juju"}, args...)50 localArgs := append([]string{"-test.run", "TestRunMain", "-run-main", "--", "juju"}, args...)
48 ps := exec.Command(os.Args[0], localArgs...)51 ps := exec.Command(os.Args[0], localArgs...)
49 ps.Env = append(os.Environ(), "JUJU_HOME="+config.JujuHome())52 ps.Env = append(os.Environ(), osenv.JujuHome+"="+config.JujuHome())
50 output, err := ps.CombinedOutput()53 output, err := ps.CombinedOutput()
51 if exit != 0 {54 if exit != 0 {
52 c.Assert(err, ErrorMatches, fmt.Sprintf("exit status %d", exit))55 c.Assert(err, ErrorMatches, fmt.Sprintf("exit status %d", exit))
5356
=== modified file 'cmd/jujud/machine.go'
--- cmd/jujud/machine.go 2013-07-30 16:39:37 +0000
+++ cmd/jujud/machine.go 2013-07-31 21:52:25 +0000
@@ -17,6 +17,7 @@
17 localstorage "launchpad.net/juju-core/environs/local/storage"17 localstorage "launchpad.net/juju-core/environs/local/storage"
18 "launchpad.net/juju-core/environs/provider"18 "launchpad.net/juju-core/environs/provider"
19 "launchpad.net/juju-core/instance"19 "launchpad.net/juju-core/instance"
20 "launchpad.net/juju-core/juju/osenv"
20 "launchpad.net/juju-core/log"21 "launchpad.net/juju-core/log"
21 "launchpad.net/juju-core/names"22 "launchpad.net/juju-core/names"
22 "launchpad.net/juju-core/state"23 "launchpad.net/juju-core/state"
@@ -222,7 +223,7 @@
222 // containers, it is likely that we will want an LXC provisioner on a KVM223 // containers, it is likely that we will want an LXC provisioner on a KVM
223 // machine, and once we get nested LXC containers, we can remove this224 // machine, and once we get nested LXC containers, we can remove this
224 // check.225 // check.
225 providerType := os.Getenv("JUJU_PROVIDER_TYPE")226 providerType := os.Getenv(osenv.JujuProviderType)
226 if providerType != provider.Local && m.ContainerType() != instance.LXC {227 if providerType != provider.Local && m.ContainerType() != instance.LXC {
227 workerName := fmt.Sprintf("%s-provisioner", provisioner.LXC)228 workerName := fmt.Sprintf("%s-provisioner", provisioner.LXC)
228 runner.StartWorker(workerName, func() (worker.Worker, error) {229 runner.StartWorker(workerName, func() (worker.Worker, error) {
229230
=== modified file 'cmd/jujud/upgradevalidation.go'
--- cmd/jujud/upgradevalidation.go 2013-07-30 16:30:58 +0000
+++ cmd/jujud/upgradevalidation.go 2013-07-31 21:52:25 +0000
@@ -14,6 +14,7 @@
14 "launchpad.net/juju-core/container/lxc"14 "launchpad.net/juju-core/container/lxc"
15 "launchpad.net/juju-core/environs/provider"15 "launchpad.net/juju-core/environs/provider"
16 "launchpad.net/juju-core/instance"16 "launchpad.net/juju-core/instance"
17 "launchpad.net/juju-core/juju/osenv"
17 "launchpad.net/juju-core/names"18 "launchpad.net/juju-core/names"
18 "launchpad.net/juju-core/state"19 "launchpad.net/juju-core/state"
19 "launchpad.net/juju-core/state/api"20 "launchpad.net/juju-core/state/api"
@@ -66,7 +67,7 @@
66 return err67 return err
67 }68 }
68 containerType := state.ContainerTypeFromId(id)69 containerType := state.ContainerTypeFromId(id)
69 providerType := os.Getenv("JUJU_PROVIDER_TYPE")70 providerType := os.Getenv(osenv.JujuProviderType)
70 if providerType == provider.Local || containerType == instance.LXC {71 if providerType == provider.Local || containerType == instance.LXC {
71 return nil72 return nil
72 }73 }
7374
=== modified file 'environs/azure/customdata_test.go'
--- environs/azure/customdata_test.go 2013-07-29 15:15:41 +0000
+++ environs/azure/customdata_test.go 2013-07-31 21:52:25 +0000
@@ -40,7 +40,6 @@
40 Addrs: []string{"127.0.0.1:123"},40 Addrs: []string{"127.0.0.1:123"},
41 Tag: names.MachineTag(machineID),41 Tag: names.MachineTag(machineID),
42 },42 },
43 ProviderType: "azure",
44 }43 }
45}44}
4645
4746
=== modified file 'environs/cloudinit.go'
--- environs/cloudinit.go 2013-07-19 18:26:41 +0000
+++ environs/cloudinit.go 2013-07-31 21:52:25 +0000
@@ -10,6 +10,7 @@
10 "launchpad.net/juju-core/constraints"10 "launchpad.net/juju-core/constraints"
11 "launchpad.net/juju-core/environs/cloudinit"11 "launchpad.net/juju-core/environs/cloudinit"
12 "launchpad.net/juju-core/environs/config"12 "launchpad.net/juju-core/environs/config"
13 "launchpad.net/juju-core/juju/osenv"
13 "launchpad.net/juju-core/state"14 "launchpad.net/juju-core/state"
14 "launchpad.net/juju-core/state/api"15 "launchpad.net/juju-core/state/api"
15 "launchpad.net/juju-core/utils"16 "launchpad.net/juju-core/utils"
@@ -69,7 +70,10 @@
69 return fmt.Errorf("environment configuration has no authorized-keys")70 return fmt.Errorf("environment configuration has no authorized-keys")
70 }71 }
71 mcfg.AuthorizedKeys = authKeys72 mcfg.AuthorizedKeys = authKeys
72 mcfg.ProviderType = cfg.Type()73 if mcfg.MachineEnvironment == nil {
74 mcfg.MachineEnvironment = make(map[string]string)
75 }
76 mcfg.MachineEnvironment[osenv.JujuProviderType] = cfg.Type()
73 if !mcfg.StateServer {77 if !mcfg.StateServer {
74 return nil78 return nil
75 }79 }
7680
=== modified file 'environs/cloudinit/cloudinit.go'
--- environs/cloudinit/cloudinit.go 2013-07-30 16:30:58 +0000
+++ environs/cloudinit/cloudinit.go 2013-07-31 21:52:25 +0000
@@ -92,8 +92,9 @@
92 // commands cannot work.92 // commands cannot work.
93 AuthorizedKeys string93 AuthorizedKeys string
9494
95 // ProviderType refers to the type of the provider that created the machine.95 // MachineEnvironment defines additional environment variables to set in
96 ProviderType string96 // the machine agent upstart script.
97 MachineEnvironment map[string]string
9798
98 // Config holds the initial environment configuration.99 // Config holds the initial environment configuration.
99 Config *config.Config100 Config *config.Config
@@ -292,7 +293,7 @@
292 addScripts(c, fmt.Sprintf("ln -s %v %s", cfg.Tools.Version, shquote(toolsDir)))293 addScripts(c, fmt.Sprintf("ln -s %v %s", cfg.Tools.Version, shquote(toolsDir)))
293294
294 name := "jujud-" + tag295 name := "jujud-" + tag
295 conf := upstart.MachineAgentUpstartService(name, toolsDir, cfg.DataDir, "/var/log/juju/", tag, machineId, logConfig, cfg.ProviderType)296 conf := upstart.MachineAgentUpstartService(name, toolsDir, cfg.DataDir, "/var/log/juju/", tag, machineId, logConfig, cfg.MachineEnvironment)
296 cmds, err := conf.InstallCommands()297 cmds, err := conf.InstallCommands()
297 if err != nil {298 if err != nil {
298 return fmt.Errorf("cannot make cloud-init upstart script for the %s agent: %v", tag, err)299 return fmt.Errorf("cannot make cloud-init upstart script for the %s agent: %v", tag, err)
@@ -398,9 +399,6 @@
398 if len(cfg.APIInfo.CACert) == 0 {399 if len(cfg.APIInfo.CACert) == 0 {
399 return fmt.Errorf("missing API CA certificate")400 return fmt.Errorf("missing API CA certificate")
400 }401 }
401 if cfg.ProviderType == "" {
402 return fmt.Errorf("missing provider type")
403 }
404 if cfg.StateServer {402 if cfg.StateServer {
405 if cfg.Config == nil {403 if cfg.Config == nil {
406 return fmt.Errorf("missing environment configuration")404 return fmt.Errorf("missing environment configuration")
407405
=== modified file 'environs/cloudinit/cloudinit_test.go'
--- environs/cloudinit/cloudinit_test.go 2013-07-24 16:08:50 +0000
+++ environs/cloudinit/cloudinit_test.go 2013-07-31 21:52:25 +0000
@@ -17,6 +17,7 @@
17 "launchpad.net/juju-core/environs"17 "launchpad.net/juju-core/environs"
18 "launchpad.net/juju-core/environs/cloudinit"18 "launchpad.net/juju-core/environs/cloudinit"
19 "launchpad.net/juju-core/environs/config"19 "launchpad.net/juju-core/environs/config"
20 "launchpad.net/juju-core/juju/osenv"
20 "launchpad.net/juju-core/state"21 "launchpad.net/juju-core/state"
21 "launchpad.net/juju-core/state/api"22 "launchpad.net/juju-core/state/api"
22 "launchpad.net/juju-core/testing"23 "launchpad.net/juju-core/testing"
@@ -58,9 +59,9 @@
58 {59 {
59 // precise state server60 // precise state server
60 cfg: cloudinit.MachineConfig{61 cfg: cloudinit.MachineConfig{
61 MachineId: "0",62 MachineId: "0",
62 AuthorizedKeys: "sshkey1",63 AuthorizedKeys: "sshkey1",
63 ProviderType: "dummy",64 MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"},
64 // precise currently needs mongo from PPA65 // precise currently needs mongo from PPA
65 Tools: newSimpleTools("1.2.3-precise-amd64"),66 Tools: newSimpleTools("1.2.3-precise-amd64"),
66 StateServer: true,67 StateServer: true,
@@ -116,9 +117,9 @@
116 }, {117 }, {
117 // raring state server118 // raring state server
118 cfg: cloudinit.MachineConfig{119 cfg: cloudinit.MachineConfig{
119 MachineId: "0",120 MachineId: "0",
120 AuthorizedKeys: "sshkey1",121 AuthorizedKeys: "sshkey1",
121 ProviderType: "dummy",122 MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"},
122 // raring provides mongo in the archive123 // raring provides mongo in the archive
123 Tools: newSimpleTools("1.2.3-raring-amd64"),124 Tools: newSimpleTools("1.2.3-raring-amd64"),
124 StateServer: true,125 StateServer: true,
@@ -173,13 +174,13 @@
173`,174`,
174 }, {175 }, {
175 cfg: cloudinit.MachineConfig{176 cfg: cloudinit.MachineConfig{
176 MachineId: "99",177 MachineId: "99",
177 AuthorizedKeys: "sshkey1",178 AuthorizedKeys: "sshkey1",
178 ProviderType: "dummy",179 MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"},
179 DataDir: environs.DataDir,180 DataDir: environs.DataDir,
180 StateServer: false,181 StateServer: false,
181 Tools: newSimpleTools("1.2.3-linux-amd64"),182 Tools: newSimpleTools("1.2.3-linux-amd64"),
182 MachineNonce: "FAKE_NONCE",183 MachineNonce: "FAKE_NONCE",
183 StateInfo: &state.Info{184 StateInfo: &state.Info{
184 Addrs: []string{"state-addr.testing.invalid:12345"},185 Addrs: []string{"state-addr.testing.invalid:12345"},
185 Tag: "machine-99",186 Tag: "machine-99",
@@ -215,7 +216,7 @@
215 MachineId: "2/lxc/1",216 MachineId: "2/lxc/1",
216 MachineContainerType: "lxc",217 MachineContainerType: "lxc",
217 AuthorizedKeys: "sshkey1",218 AuthorizedKeys: "sshkey1",
218 ProviderType: "dummy",219 MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"},
219 DataDir: environs.DataDir,220 DataDir: environs.DataDir,
220 StateServer: false,221 StateServer: false,
221 Tools: newSimpleTools("1.2.3-linux-amd64"),222 Tools: newSimpleTools("1.2.3-linux-amd64"),
@@ -557,15 +558,15 @@
557// checked for by NewCloudInit.558// checked for by NewCloudInit.
558func (*cloudinitSuite) TestCloudInitVerify(c *C) {559func (*cloudinitSuite) TestCloudInitVerify(c *C) {
559 cfg := &cloudinit.MachineConfig{560 cfg := &cloudinit.MachineConfig{
560 StateServer: true,561 StateServer: true,
561 StateServerCert: serverCert,562 StateServerCert: serverCert,
562 StateServerKey: serverKey,563 StateServerKey: serverKey,
563 StatePort: 1234,564 StatePort: 1234,
564 APIPort: 1235,565 APIPort: 1235,
565 MachineId: "99",566 MachineId: "99",
566 Tools: newSimpleTools("9.9.9-linux-arble"),567 Tools: newSimpleTools("9.9.9-linux-arble"),
567 AuthorizedKeys: "sshkey1",568 AuthorizedKeys: "sshkey1",
568 ProviderType: "dummy",569 MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"},
569 StateInfo: &state.Info{570 StateInfo: &state.Info{
570 Addrs: []string{"host:98765"},571 Addrs: []string{"host:98765"},
571 CACert: []byte(testing.CACert),572 CACert: []byte(testing.CACert),
572573
=== modified file 'environs/cloudinit_test.go'
--- environs/cloudinit_test.go 2013-07-24 16:08:50 +0000
+++ environs/cloudinit_test.go 2013-07-31 21:52:25 +0000
@@ -15,6 +15,7 @@
15 "launchpad.net/juju-core/environs"15 "launchpad.net/juju-core/environs"
16 "launchpad.net/juju-core/environs/cloudinit"16 "launchpad.net/juju-core/environs/cloudinit"
17 "launchpad.net/juju-core/environs/config"17 "launchpad.net/juju-core/environs/config"
18 "launchpad.net/juju-core/juju/osenv"
18 "launchpad.net/juju-core/state"19 "launchpad.net/juju-core/state"
19 "launchpad.net/juju-core/state/api"20 "launchpad.net/juju-core/state/api"
20 "launchpad.net/juju-core/testing"21 "launchpad.net/juju-core/testing"
@@ -42,10 +43,10 @@
42 err = environs.FinishMachineConfig(mcfg, cfg, constraints.Value{})43 err = environs.FinishMachineConfig(mcfg, cfg, constraints.Value{})
43 c.Assert(err, IsNil)44 c.Assert(err, IsNil)
44 c.Assert(mcfg, DeepEquals, &cloudinit.MachineConfig{45 c.Assert(mcfg, DeepEquals, &cloudinit.MachineConfig{
45 AuthorizedKeys: "we-are-the-keys",46 AuthorizedKeys: "we-are-the-keys",
46 ProviderType: "dummy",47 MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"},
47 StateInfo: &state.Info{Tag: "not touched"},48 StateInfo: &state.Info{Tag: "not touched"},
48 APIInfo: &api.Info{Tag: "not touched"},49 APIInfo: &api.Info{Tag: "not touched"},
49 })50 })
50}51}
5152
@@ -128,12 +129,12 @@
128 Password: "pw2",129 Password: "pw2",
129 CACert: []byte("CA CERT\n" + testing.CACert),130 CACert: []byte("CA CERT\n" + testing.CACert),
130 },131 },
131 DataDir: environs.DataDir,132 DataDir: environs.DataDir,
132 Config: envConfig,133 Config: envConfig,
133 StatePort: envConfig.StatePort(),134 StatePort: envConfig.StatePort(),
134 APIPort: envConfig.APIPort(),135 APIPort: envConfig.APIPort(),
135 StateServer: true,136 StateServer: true,
136 ProviderType: "dummy",137 MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"},
137 }138 }
138 script1 := "script1"139 script1 := "script1"
139 script2 := "script2"140 script2 := "script2"
140141
=== modified file 'environs/local/environ.go'
--- environs/local/environ.go 2013-07-30 16:39:37 +0000
+++ environs/local/environ.go 2013-07-31 21:52:25 +0000
@@ -21,6 +21,7 @@
21 "launchpad.net/juju-core/environs/config"21 "launchpad.net/juju-core/environs/config"
22 "launchpad.net/juju-core/environs/localstorage"22 "launchpad.net/juju-core/environs/localstorage"
23 "launchpad.net/juju-core/instance"23 "launchpad.net/juju-core/instance"
24 "launchpad.net/juju-core/juju/osenv"
24 "launchpad.net/juju-core/names"25 "launchpad.net/juju-core/names"
25 "launchpad.net/juju-core/state"26 "launchpad.net/juju-core/state"
26 "launchpad.net/juju-core/state/api"27 "launchpad.net/juju-core/state/api"
@@ -464,15 +465,18 @@
464 toolsDir := tools.SharedToolsDir(dataDir, agentTools.Version)465 toolsDir := tools.SharedToolsDir(dataDir, agentTools.Version)
465 logDir := env.config.logDir()466 logDir := env.config.logDir()
466 logConfig := "--debug" // TODO(thumper): specify loggo config467 logConfig := "--debug" // TODO(thumper): specify loggo config
468 machineEnvironment := map[string]string{
469 "USER": env.config.user,
470 "HOME": os.Getenv("HOME"),
471 osenv.JujuProviderType: env.config.Type(),
472 osenv.JujuStorageDir: env.config.storageDir(),
473 osenv.JujuStorageAddr: env.config.storageAddr(),
474 osenv.JujuSharedStorageDir: env.config.sharedStorageDir(),
475 osenv.JujuSharedStorageAddr: env.config.sharedStorageAddr(),
476 }
467 agent := upstart.MachineAgentUpstartService(477 agent := upstart.MachineAgentUpstartService(
468 env.machineAgentServiceName(),478 env.machineAgentServiceName(),
469 toolsDir, dataDir, logDir, tag, machineId, logConfig, env.config.Type())479 toolsDir, dataDir, logDir, tag, machineId, logConfig, machineEnvironment)
470 agent.Env["USER"] = env.config.user
471 agent.Env["HOME"] = os.Getenv("HOME")
472 agent.Env["JUJU_STORAGE_DIR"] = env.config.storageDir()
473 agent.Env["JUJU_STORAGE_ADDR"] = env.config.storageAddr()
474 agent.Env["JUJU_SHARED_STORAGE_DIR"] = env.config.sharedStorageDir()
475 agent.Env["JUJU_SHARED_STORAGE_ADDR"] = env.config.sharedStorageAddr()
476480
477 agent.InitDir = upstartScriptLocation481 agent.InitDir = upstartScriptLocation
478 logger.Infof("installing service %s to %s", env.machineAgentServiceName(), agent.InitDir)482 logger.Infof("installing service %s to %s", env.machineAgentServiceName(), agent.InitDir)
479483
=== modified file 'environs/local/storage/worker.go'
--- environs/local/storage/worker.go 2013-07-16 02:09:30 +0000
+++ environs/local/storage/worker.go 2013-07-31 21:52:25 +0000
@@ -7,6 +7,7 @@
7 "launchpad.net/tomb"7 "launchpad.net/tomb"
88
9 "launchpad.net/juju-core/environs/localstorage"9 "launchpad.net/juju-core/environs/localstorage"
10 "launchpad.net/juju-core/juju/osenv"
10 "launchpad.net/juju-core/worker"11 "launchpad.net/juju-core/worker"
11)12)
1213
@@ -36,8 +37,8 @@
36}37}
3738
38func (s *storageWorker) waitForDeath() error {39func (s *storageWorker) waitForDeath() error {
39 storageDir := os.Getenv("JUJU_STORAGE_DIR")40 storageDir := os.Getenv(osenv.JujuStorageDir)
40 storageAddr := os.Getenv("JUJU_STORAGE_ADDR")41 storageAddr := os.Getenv(osenv.JujuStorageAddr)
41 logger.Infof("serving %s on %s", storageDir, storageAddr)42 logger.Infof("serving %s on %s", storageDir, storageAddr)
4243
43 storageListener, err := localstorage.Serve(storageAddr, storageDir)44 storageListener, err := localstorage.Serve(storageAddr, storageDir)
@@ -47,8 +48,8 @@
47 }48 }
48 defer storageListener.Close()49 defer storageListener.Close()
4950
50 sharedStorageDir := os.Getenv("JUJU_SHARED_STORAGE_DIR")51 sharedStorageDir := os.Getenv(osenv.JujuSharedStorageDir)
51 sharedStorageAddr := os.Getenv("JUJU_SHARED_STORAGE_ADDR")52 sharedStorageAddr := os.Getenv(osenv.JujuSharedStorageAddr)
52 logger.Infof("serving %s on %s", sharedStorageDir, sharedStorageAddr)53 logger.Infof("serving %s on %s", sharedStorageDir, sharedStorageAddr)
5354
54 sharedStorageListener, err := localstorage.Serve(sharedStorageAddr, sharedStorageDir)55 sharedStorageListener, err := localstorage.Serve(sharedStorageAddr, sharedStorageDir)
5556
=== added directory 'juju/osenv'
=== added file 'juju/osenv/package_test.go'
--- juju/osenv/package_test.go 1970-01-01 00:00:00 +0000
+++ juju/osenv/package_test.go 2013-07-31 21:52:25 +0000
@@ -0,0 +1,14 @@
1// Copyright 2013 Canonical Ltd.
2// Licensed under the AGPLv3, see LICENCE file for details.
3
4package osenv_test
5
6import (
7 "testing"
8
9 gc "launchpad.net/gocheck"
10)
11
12func Test(t *testing.T) {
13 gc.TestingT(t)
14}
015
=== added file 'juju/osenv/vars.go'
--- juju/osenv/vars.go 1970-01-01 00:00:00 +0000
+++ juju/osenv/vars.go 2013-07-31 21:52:25 +0000
@@ -0,0 +1,16 @@
1// Copyright 2013 Canonical Ltd.
2// Licensed under the AGPLv3, see LICENCE file for details.
3
4package osenv
5
6const (
7 JujuEnv = "JUJU_ENV"
8 JujuHome = "JUJU_HOME"
9 JujuRepository = "JUJU_REPOSITORY"
10 JujuLxcBridge = "JUJU_LXC_BRIDGE"
11 JujuProviderType = "JUJU_PROVIDER_TYPE"
12 JujuStorageDir = "JUJU_STORAGE_DIR"
13 JujuStorageAddr = "JUJU_STORAGE_ADDR"
14 JujuSharedStorageDir = "JUJU_SHARED_STORAGE_DIR"
15 JujuSharedStorageAddr = "JUJU_SHARED_STORAGE_ADDR"
16)
017
=== added file 'juju/osenv/vars_test.go'
--- juju/osenv/vars_test.go 1970-01-01 00:00:00 +0000
+++ juju/osenv/vars_test.go 2013-07-31 21:52:25 +0000
@@ -0,0 +1,20 @@
1// Copyright 2013 Canonical Ltd.
2// Licensed under the AGPLv3, see LICENCE file for details.
3
4package osenv_test
5
6import (
7 gc "launchpad.net/gocheck"
8
9 "launchpad.net/juju-core/testing"
10)
11
12type importSuite struct{}
13
14var _ = gc.Suite(&importSuite{})
15
16func (*importSuite) TestDependencies(c *gc.C) {
17 // This test is to ensure we don't bring in dependencies at all.
18 c.Assert(testing.FindJujuCoreImports(c, "launchpad.net/juju-core/juju/osenv"),
19 gc.HasLen, 0)
20}
021
=== modified file 'upstart/service.go'
--- upstart/service.go 2013-07-16 06:29:04 +0000
+++ upstart/service.go 2013-07-31 21:52:25 +0000
@@ -42,7 +42,7 @@
4242
43// MachineAgentUpstartService returns the upstart config for a machine agent43// MachineAgentUpstartService returns the upstart config for a machine agent
44// based on the tag and machineId passed in.44// based on the tag and machineId passed in.
45func MachineAgentUpstartService(name, toolsDir, dataDir, logDir, tag, machineId, logConfig, providerType string) *Conf {45func MachineAgentUpstartService(name, toolsDir, dataDir, logDir, tag, machineId, logConfig string, env map[string]string) *Conf {
46 svc := NewService(name)46 svc := NewService(name)
47 logFile := filepath.Join(logDir, tag+".log")47 logFile := filepath.Join(logDir, tag+".log")
48 return &Conf{48 return &Conf{
@@ -58,8 +58,6 @@
58 " --machine-id " + machineId +58 " --machine-id " + machineId +
59 " " + logConfig,59 " " + logConfig,
60 Out: logFile,60 Out: logFile,
61 Env: map[string]string{61 Env: env,
62 "JUJU_PROVIDER_TYPE": providerType,
63 },
64 }62 }
65}63}
6664
=== modified file 'worker/deployer/simple.go'
--- worker/deployer/simple.go 2013-07-30 14:00:53 +0000
+++ worker/deployer/simple.go 2013-07-31 21:52:25 +0000
@@ -13,6 +13,7 @@
1313
14 "launchpad.net/juju-core/agent"14 "launchpad.net/juju-core/agent"
15 "launchpad.net/juju-core/agent/tools"15 "launchpad.net/juju-core/agent/tools"
16 "launchpad.net/juju-core/juju/osenv"
16 "launchpad.net/juju-core/log/syslog"17 "launchpad.net/juju-core/log/syslog"
17 "launchpad.net/juju-core/names"18 "launchpad.net/juju-core/names"
18 "launchpad.net/juju-core/state" // Only because of state.Info19 "launchpad.net/juju-core/state" // Only because of state.Info
@@ -148,7 +149,7 @@
148 Out: logPath,149 Out: logPath,
149 // Propagate the provider type enviroment variable.150 // Propagate the provider type enviroment variable.
150 Env: map[string]string{151 Env: map[string]string{
151 "JUJU_PROVIDER_TYPE": os.Getenv("JUJU_PROVIDER_TYPE"),152 osenv.JujuProviderType: os.Getenv(osenv.JujuProviderType),
152 },153 },
153 }154 }
154 return uconf.Install()155 return uconf.Install()

Subscribers

People subscribed via source and target branches

to status/vote changes: