Merge lp:~dave-cheney/juju-core/113-juju-bootstrap-raring-cloudinit-II into lp:~juju/juju-core/trunk

Proposed by Dave Cheney
Status: Rejected
Rejected by: Dave Cheney
Proposed branch: lp:~dave-cheney/juju-core/113-juju-bootstrap-raring-cloudinit-II
Merge into: lp:~juju/juju-core/trunk
Diff against target: 454 lines (+158/-137)
6 files modified
environs/cloudinit/cloudinit.go (+12/-8)
environs/cloudinit/cloudinit_test.go (+146/-57)
environs/ec2/ec2.go (+0/-4)
environs/mongo.go (+0/-48)
environs/mongo_test.go (+0/-16)
environs/openstack/provider.go (+0/-4)
To merge this branch: bzr merge lp:~dave-cheney/juju-core/113-juju-bootstrap-raring-cloudinit-II
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+158263@code.launchpad.net

Description of the change

source mongo from package

This proposal replaces the source of mongo for state servers. Mongo is now installed from a package. The source of this package differs depending on the series of the machine being bootstrapped (which is itself drawn from the tools installed on the machine). For P and Q, the source is a PPA owned by the Juju team. For R and above, mongo is available in the archive.

To post a comment you must log in.

Unmerged revisions

1130. By Dave Cheney

tweaks

1129. By Dave Cheney

gofmt

1128. By Dave Cheney

merge from trunk

1127. By Dave Cheney

re add mongo.go

1126. By Dave Cheney

wip

1125. By Dave Cheney

gofmt

1124. By Dave Cheney

remove MongoURL

1123. By Roger Peppe

state: use one schema for status

When implementing the allWatcher, it helps
to have a single doc type per collection.

R=dimitern, fwereade
CC=
https://codereview.appspot.com/8510043

1122. By Frank Mueller

state: add environment persistency with UUID

Changed environment to be stored using an own document
in an own collection. Currently it only stores the name
and the UUID of the environment. The latter is generated
during the initializing of the state. Both, name and
UUID cannot be changed. The UUID will be passed as the
environment variable $JUJU_ENV_UUID to the charm hooks.

R=fwereade, dimitern
CC=
https://codereview.appspot.com/8322043

1121. By Dimiter Naydenov

environs: add machineNonce to StartInstance()

Continuing from the previous CL, this propagates
the machine nonce throughout environs.

Now the machineNonce is passed to StartInstance()
in all providers. In a follow-up the support for
handling nonces in state will be added.

R=fwereade, rog, TheMue
CC=
https://codereview.appspot.com/8429044

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/cloudinit/cloudinit.go'
2--- environs/cloudinit/cloudinit.go 2013-04-05 15:47:26 +0000
3+++ environs/cloudinit/cloudinit.go 2013-04-11 02:04:22 +0000
4@@ -60,9 +60,6 @@
5 // Tools is juju tools to be used on the new machine.
6 Tools *state.Tools
7
8- // MongoURL is used to retrieve the mongodb tarball.
9- MongoURL string
10-
11 // DataDir holds the directory that juju state will be put in the new
12 // machine.
13 DataDir string
14@@ -130,12 +127,12 @@
15
16 var syslogConfigRenderer syslog.SyslogConfigRenderer
17 if cfg.StateServer {
18+ if cfg.NeedMongoPPA() {
19+ c.AddAptSource("ppa:juju/experimental", "1024R/C8068B11")
20+ }
21+ c.AddPackage("mongodb-server")
22 certKey := string(cfg.StateServerCert) + string(cfg.StateServerKey)
23 addFile(c, cfg.dataFile("server.pem"), certKey, 0600)
24- addScripts(c,
25- "mkdir -p /opt",
26- fmt.Sprintf("wget --no-verbose -O - %s | tar xz -C /opt", shquote(cfg.MongoURL)),
27- )
28 if err := addMongoToBoot(c, cfg); err != nil {
29 return nil, err
30 }
31@@ -283,7 +280,7 @@
32 conf := &upstart.Conf{
33 Service: *svc,
34 Desc: "juju state database",
35- Cmd: "/opt/mongo/bin/mongod" +
36+ Cmd: "/usr/bin/mongod" +
37 " --auth" +
38 " --dbpath=/var/lib/juju/db" +
39 " --sslOnNormalPorts" +
40@@ -337,6 +334,13 @@
41 return hosts
42 }
43
44+func (cfg *MachineConfig) NeedMongoPPA() bool {
45+ series := cfg.Tools.Series
46+ // 11.10 and earlier are not supported.
47+ // 13.04 and later ship a compatible version in the archive.
48+ return series == "precise" || series == "quantal"
49+}
50+
51 func shquote(p string) string {
52 return trivial.ShQuote(p)
53 }
54
55=== modified file 'environs/cloudinit/cloudinit_test.go'
56--- environs/cloudinit/cloudinit_test.go 2013-04-05 15:47:26 +0000
57+++ environs/cloudinit/cloudinit_test.go 2013-04-11 02:04:22 +0000
58@@ -46,63 +46,116 @@
59
60 // Each test gives a cloudinit config - we check the
61 // output to see if it looks correct.
62-var cloudinitTests = []cloudinitTest{{
63- cfg: cloudinit.MachineConfig{
64- MachineId: "0",
65- AuthorizedKeys: "sshkey1",
66- Tools: newSimpleTools("1.2.3-linux-amd64"),
67- MongoURL: "http://juju-dist.host.com/mongodb.tar.gz",
68- StateServer: true,
69- StateServerCert: serverCert,
70- StateServerKey: serverKey,
71- MongoPort: 37017,
72- APIPort: 17070,
73- MachineNonce: "FAKE_NONCE",
74- StateInfo: &state.Info{
75- Password: "arble",
76- CACert: []byte("CA CERT\n" + testing.CACert),
77- },
78- APIInfo: &api.Info{
79- Password: "bletch",
80- CACert: []byte("CA CERT\n" + testing.CACert),
81- },
82- Constraints: envConstraints,
83- DataDir: "/var/lib/juju",
84- },
85- setEnvConfig: true,
86- expectScripts: `
87-mkdir -p /var/lib/juju
88-mkdir -p /var/log/juju
89-bin='/var/lib/juju/tools/1\.2\.3-linux-amd64'
90-mkdir -p \$bin
91-wget --no-verbose -O - 'http://foo\.com/tools/juju1\.2\.3-linux-amd64\.tgz' \| tar xz -C \$bin
92-echo -n 'http://foo\.com/tools/juju1\.2\.3-linux-amd64\.tgz' > \$bin/downloaded-url\.txt
93-echo 'SERVER CERT\\n[^']*SERVER KEY\\n[^']*' > '/var/lib/juju/server\.pem'
94-chmod 600 '/var/lib/juju/server\.pem'
95-mkdir -p /opt
96-wget --no-verbose -O - 'http://juju-dist\.host\.com/mongodb\.tar\.gz' \| tar xz -C /opt
97-mkdir -p /var/lib/juju/db/journal
98-dd bs=1M count=1 if=/dev/zero of=/var/lib/juju/db/journal/prealloc\.0
99-dd bs=1M count=1 if=/dev/zero of=/var/lib/juju/db/journal/prealloc\.1
100-dd bs=1M count=1 if=/dev/zero of=/var/lib/juju/db/journal/prealloc\.2
101-cat >> /etc/init/juju-db\.conf << 'EOF'\\ndescription "juju state database"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit 0\\n\\nexec /opt/mongo/bin/mongod --auth --dbpath=/var/lib/juju/db --sslOnNormalPorts --sslPEMKeyFile '/var/lib/juju/server\.pem' --sslPEMKeyPassword ignored --bind_ip 0\.0\.0\.0 --port 37017 --noprealloc --smallfiles\\nEOF\\n
102-start juju-db
103-mkdir -p '/var/lib/juju/agents/bootstrap'
104-echo 'datadir: /var/lib/juju\\nstateservercert:\\n[^']+stateserverkey:\\n[^']+mongoport: 37017\\napiport: 17070\\noldpassword: arble\\nmachinenonce: FAKE_NONCE\\nstateinfo:\\n addrs:\\n - localhost:37017\\n cacert:\\n[^']+ tag: bootstrap\\n password: ""\\noldapipassword: ""\\napiinfo:\\n addrs:\\n - localhost:17070\\n cacert:\\n[^']+ tag: bootstrap\\n password: ""\\n' > '/var/lib/juju/agents/bootstrap/agent\.conf'
105-chmod 600 '/var/lib/juju/agents/bootstrap/agent\.conf'
106-/var/lib/juju/tools/1\.2\.3-linux-amd64/jujud bootstrap-state --data-dir '/var/lib/juju' --env-config '[^']*' --constraints 'mem=2048M' --debug
107-rm -rf '/var/lib/juju/agents/bootstrap'
108-cat > /etc/rsyslog.d/25-juju.conf << 'EOF'\\n\\n\$ModLoad imfile\\n\\n\$InputFilePollInterval 5\\n\$InputFileName /var/log/juju/machine-0.log\\n\$InputFileTag local-juju-machine-0:\\n\$InputFileStateFile machine-0\\n\$InputRunFileMonitor\\n\\n\$ModLoad imudp\\n\$UDPServerRun 514\\n\\n# Messages received from remote rsyslog machines contain a leading space so we\\n# need to account for that.\\n\$template JujuLogFormatLocal,\"%HOSTNAME%:%msg:::drop-last-lf%\\n\"\\n\$template JujuLogFormat,\"%HOSTNAME%:%msg:2:2048:drop-last-lf%\\n\"\\n\\n:syslogtag, startswith, \"juju-\" /var/log/juju/all-machines.log;JujuLogFormat\\n:syslogtag, startswith, \"local-juju-\" /var/log/juju/all-machines.log;JujuLogFormatLocal\\n& ~\\nEOF\\n
109-restart rsyslog
110-mkdir -p '/var/lib/juju/agents/machine-0'
111-echo 'datadir: /var/lib/juju\\nstateservercert:\\n[^']+stateserverkey:\\n[^']+mongoport: 37017\\napiport: 17070\\noldpassword: arble\\nmachinenonce: FAKE_NONCE\\nstateinfo:\\n addrs:\\n - localhost:37017\\n cacert:\\n[^']+ tag: machine-0\\n password: ""\\noldapipassword: ""\\napiinfo:\\n addrs:\\n - localhost:17070\\n cacert:\\n[^']+ tag: machine-0\\n password: ""\\n' > '/var/lib/juju/agents/machine-0/agent\.conf'
112-chmod 600 '/var/lib/juju/agents/machine-0/agent\.conf'
113-ln -s 1\.2\.3-linux-amd64 '/var/lib/juju/tools/machine-0'
114-cat >> /etc/init/jujud-machine-0\.conf << 'EOF'\\ndescription "juju machine-0 agent"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit 0\\n\\nexec /var/lib/juju/tools/machine-0/jujud machine --log-file /var/log/juju/machine-0\.log --data-dir '/var/lib/juju' --machine-id 0 --debug >> /var/log/juju/machine-0\.log 2>&1\\nEOF\\n
115-start jujud-machine-0
116-`,
117-},
118+var cloudinitTests = []cloudinitTest{
119 {
120+ // precise state server
121+ cfg: cloudinit.MachineConfig{
122+ MachineId: "0",
123+ AuthorizedKeys: "sshkey1",
124+ // precise currently needs mongo from PPA
125+ Tools: newSimpleTools("1.2.3-precise-amd64"),
126+ StateServer: true,
127+ StateServerCert: serverCert,
128+ StateServerKey: serverKey,
129+ MongoPort: 37017,
130+ APIPort: 17070,
131+ MachineNonce: "FAKE_NONCE",
132+ StateInfo: &state.Info{
133+ Password: "arble",
134+ CACert: []byte("CA CERT\n" + testing.CACert),
135+ },
136+ APIInfo: &api.Info{
137+ Password: "bletch",
138+ CACert: []byte("CA CERT\n" + testing.CACert),
139+ },
140+ Constraints: envConstraints,
141+ DataDir: "/var/lib/juju",
142+ },
143+ setEnvConfig: true,
144+ expectScripts: `
145+mkdir -p /var/lib/juju
146+mkdir -p /var/log/juju
147+bin='/var/lib/juju/tools/1\.2\.3-precise-amd64'
148+mkdir -p \$bin
149+wget --no-verbose -O - 'http://foo\.com/tools/juju1\.2\.3-precise-amd64\.tgz' \| tar xz -C \$bin
150+echo -n 'http://foo\.com/tools/juju1\.2\.3-precise-amd64\.tgz' > \$bin/downloaded-url\.txt
151+echo 'SERVER CERT\\n[^']*SERVER KEY\\n[^']*' > '/var/lib/juju/server\.pem'
152+chmod 600 '/var/lib/juju/server\.pem'
153+mkdir -p /var/lib/juju/db/journal
154+dd bs=1M count=1 if=/dev/zero of=/var/lib/juju/db/journal/prealloc\.0
155+dd bs=1M count=1 if=/dev/zero of=/var/lib/juju/db/journal/prealloc\.1
156+dd bs=1M count=1 if=/dev/zero of=/var/lib/juju/db/journal/prealloc\.2
157+cat >> /etc/init/juju-db\.conf << 'EOF'\\ndescription "juju state database"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit 0\\n\\nexec /usr/bin/mongod --auth --dbpath=/var/lib/juju/db --sslOnNormalPorts --sslPEMKeyFile '/var/lib/juju/server\.pem' --sslPEMKeyPassword ignored --bind_ip 0\.0\.0\.0 --port 37017 --noprealloc --smallfiles\\nEOF\\n
158+start juju-db
159+mkdir -p '/var/lib/juju/agents/bootstrap'
160+echo 'datadir: /var/lib/juju\\nstateservercert:\\n[^']+stateserverkey:\\n[^']+mongoport: 37017\\napiport: 17070\\noldpassword: arble\\nmachinenonce: FAKE_NONCE\\nstateinfo:\\n addrs:\\n - localhost:37017\\n cacert:\\n[^']+ tag: bootstrap\\n password: ""\\noldapipassword: ""\\napiinfo:\\n addrs:\\n - localhost:17070\\n cacert:\\n[^']+ tag: bootstrap\\n password: ""\\n' > '/var/lib/juju/agents/bootstrap/agent\.conf'
161+chmod 600 '/var/lib/juju/agents/bootstrap/agent\.conf'
162+/var/lib/juju/tools/1\.2\.3-precise-amd64/jujud bootstrap-state --data-dir '/var/lib/juju' --env-config '[^']*' --constraints 'mem=2048M' --debug
163+rm -rf '/var/lib/juju/agents/bootstrap'
164+cat > /etc/rsyslog.d/25-juju.conf << 'EOF'\\n\\n\$ModLoad imfile\\n\\n\$InputFilePollInterval 5\\n\$InputFileName /var/log/juju/machine-0.log\\n\$InputFileTag local-juju-machine-0:\\n\$InputFileStateFile machine-0\\n\$InputRunFileMonitor\\n\\n\$ModLoad imudp\\n\$UDPServerRun 514\\n\\n# Messages received from remote rsyslog machines contain a leading space so we\\n# need to account for that.\\n\$template JujuLogFormatLocal,\"%HOSTNAME%:%msg:::drop-last-lf%\\n\"\\n\$template JujuLogFormat,\"%HOSTNAME%:%msg:2:2048:drop-last-lf%\\n\"\\n\\n:syslogtag, startswith, \"juju-\" /var/log/juju/all-machines.log;JujuLogFormat\\n:syslogtag, startswith, \"local-juju-\" /var/log/juju/all-machines.log;JujuLogFormatLocal\\n& ~\\nEOF\\n
165+restart rsyslog
166+mkdir -p '/var/lib/juju/agents/machine-0'
167+echo 'datadir: /var/lib/juju\\nstateservercert:\\n[^']+stateserverkey:\\n[^']+mongoport: 37017\\napiport: 17070\\noldpassword: arble\\nmachinenonce: FAKE_NONCE\\nstateinfo:\\n addrs:\\n - localhost:37017\\n cacert:\\n[^']+ tag: machine-0\\n password: ""\\noldapipassword: ""\\napiinfo:\\n addrs:\\n - localhost:17070\\n cacert:\\n[^']+ tag: machine-0\\n password: ""\\n' > '/var/lib/juju/agents/machine-0/agent\.conf'
168+chmod 600 '/var/lib/juju/agents/machine-0/agent\.conf'
169+ln -s 1\.2\.3-precise-amd64 '/var/lib/juju/tools/machine-0'
170+cat >> /etc/init/jujud-machine-0\.conf << 'EOF'\\ndescription "juju machine-0 agent"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit 0\\n\\nexec /var/lib/juju/tools/machine-0/jujud machine --log-file /var/log/juju/machine-0\.log --data-dir '/var/lib/juju' --machine-id 0 --debug >> /var/log/juju/machine-0\.log 2>&1\\nEOF\\n
171+start jujud-machine-0
172+`,
173+ }, {
174+ // raring state server
175+ cfg: cloudinit.MachineConfig{
176+ MachineId: "0",
177+ AuthorizedKeys: "sshkey1",
178+ // raring provides mongo in the archive
179+ Tools: newSimpleTools("1.2.3-raring-amd64"),
180+ StateServer: true,
181+ StateServerCert: serverCert,
182+ StateServerKey: serverKey,
183+ MongoPort: 37017,
184+ APIPort: 17070,
185+ MachineNonce: "FAKE_NONCE",
186+ StateInfo: &state.Info{
187+ Password: "arble",
188+ CACert: []byte("CA CERT\n" + testing.CACert),
189+ },
190+ APIInfo: &api.Info{
191+ Password: "bletch",
192+ CACert: []byte("CA CERT\n" + testing.CACert),
193+ },
194+ Constraints: envConstraints,
195+ DataDir: "/var/lib/juju",
196+ },
197+ setEnvConfig: true,
198+ expectScripts: `
199+mkdir -p /var/lib/juju
200+mkdir -p /var/log/juju
201+bin='/var/lib/juju/tools/1\.2\.3-raring-amd64'
202+mkdir -p \$bin
203+wget --no-verbose -O - 'http://foo\.com/tools/juju1\.2\.3-raring-amd64\.tgz' \| tar xz -C \$bin
204+echo -n 'http://foo\.com/tools/juju1\.2\.3-raring-amd64\.tgz' > \$bin/downloaded-url\.txt
205+echo 'SERVER CERT\\n[^']*SERVER KEY\\n[^']*' > '/var/lib/juju/server\.pem'
206+chmod 600 '/var/lib/juju/server\.pem'
207+mkdir -p /var/lib/juju/db/journal
208+dd bs=1M count=1 if=/dev/zero of=/var/lib/juju/db/journal/prealloc\.0
209+dd bs=1M count=1 if=/dev/zero of=/var/lib/juju/db/journal/prealloc\.1
210+dd bs=1M count=1 if=/dev/zero of=/var/lib/juju/db/journal/prealloc\.2
211+cat >> /etc/init/juju-db\.conf << 'EOF'\\ndescription "juju state database"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit 0\\n\\nexec /usr/bin/mongod --auth --dbpath=/var/lib/juju/db --sslOnNormalPorts --sslPEMKeyFile '/var/lib/juju/server\.pem' --sslPEMKeyPassword ignored --bind_ip 0\.0\.0\.0 --port 37017 --noprealloc --smallfiles\\nEOF\\n
212+start juju-db
213+mkdir -p '/var/lib/juju/agents/bootstrap'
214+echo 'datadir: /var/lib/juju\\nstateservercert:\\n[^']+stateserverkey:\\n[^']+mongoport: 37017\\napiport: 17070\\noldpassword: arble\\nmachinenonce: FAKE_NONCE\\nstateinfo:\\n addrs:\\n - localhost:37017\\n cacert:\\n[^']+ tag: bootstrap\\n password: ""\\noldapipassword: ""\\napiinfo:\\n addrs:\\n - localhost:17070\\n cacert:\\n[^']+ tag: bootstrap\\n password: ""\\n' > '/var/lib/juju/agents/bootstrap/agent\.conf'
215+chmod 600 '/var/lib/juju/agents/bootstrap/agent\.conf'
216+/var/lib/juju/tools/1\.2\.3-raring-amd64/jujud bootstrap-state --data-dir '/var/lib/juju' --env-config '[^']*' --constraints 'mem=2048M' --debug
217+rm -rf '/var/lib/juju/agents/bootstrap'
218+cat > /etc/rsyslog.d/25-juju.conf << 'EOF'\\n\\n\$ModLoad imfile\\n\\n\$InputFilePollInterval 5\\n\$InputFileName /var/log/juju/machine-0.log\\n\$InputFileTag local-juju-machine-0:\\n\$InputFileStateFile machine-0\\n\$InputRunFileMonitor\\n\\n\$ModLoad imudp\\n\$UDPServerRun 514\\n\\n# Messages received from remote rsyslog machines contain a leading space so we\\n# need to account for that.\\n\$template JujuLogFormatLocal,\"%HOSTNAME%:%msg:::drop-last-lf%\\n\"\\n\$template JujuLogFormat,\"%HOSTNAME%:%msg:2:2048:drop-last-lf%\\n\"\\n\\n:syslogtag, startswith, \"juju-\" /var/log/juju/all-machines.log;JujuLogFormat\\n:syslogtag, startswith, \"local-juju-\" /var/log/juju/all-machines.log;JujuLogFormatLocal\\n& ~\\nEOF\\n
219+restart rsyslog
220+mkdir -p '/var/lib/juju/agents/machine-0'
221+echo 'datadir: /var/lib/juju\\nstateservercert:\\n[^']+stateserverkey:\\n[^']+mongoport: 37017\\napiport: 17070\\noldpassword: arble\\nmachinenonce: FAKE_NONCE\\nstateinfo:\\n addrs:\\n - localhost:37017\\n cacert:\\n[^']+ tag: machine-0\\n password: ""\\noldapipassword: ""\\napiinfo:\\n addrs:\\n - localhost:17070\\n cacert:\\n[^']+ tag: machine-0\\n password: ""\\n' > '/var/lib/juju/agents/machine-0/agent\.conf'
222+chmod 600 '/var/lib/juju/agents/machine-0/agent\.conf'
223+ln -s 1\.2\.3-raring-amd64 '/var/lib/juju/tools/machine-0'
224+cat >> /etc/init/jujud-machine-0\.conf << 'EOF'\\ndescription "juju machine-0 agent"\\nauthor "Juju Team <juju@lists\.ubuntu\.com>"\\nstart on runlevel \[2345\]\\nstop on runlevel \[!2345\]\\nrespawn\\nnormal exit 0\\n\\nexec /var/lib/juju/tools/machine-0/jujud machine --log-file /var/log/juju/machine-0\.log --data-dir '/var/lib/juju' --machine-id 0 --debug >> /var/log/juju/machine-0\.log 2>&1\\nEOF\\n
225+start jujud-machine-0
226+`,
227+ }, {
228 cfg: cloudinit.MachineConfig{
229 MachineId: "99",
230 AuthorizedKeys: "sshkey1",
231@@ -200,6 +253,14 @@
232 checkEnvConfig(c, test.cfg.Config, x, scripts)
233 }
234 checkPackage(c, x, "git", true)
235+ if test.cfg.StateServer {
236+ checkPackage(c, x, "mongodb-server", true)
237+ source := struct{ Source, Key string }{
238+ Source: "ppa:juju/experimental",
239+ Key: "1024R/C8068B11",
240+ }
241+ checkAptSource(c, x, source, test.cfg.NeedMongoPPA())
242+ }
243 }
244 }
245
246@@ -223,7 +284,7 @@
247 case i == len(got):
248 c.Fatalf("too few scripts found (expected %q at line %d)", pats[i], i)
249 case i == len(pats):
250- c.Fatalf("too many scripts found (got %q at line %d)", got[i], i)
251+ cString.Fatalf("too many scripts found (got %q at line %d)", got[i], i)
252 }
253 script := strings.Replace(got[i], "\n", "\\n", -1) // make .* work
254 c.Assert(script, Matches, pats[i], Commentf("line %d", i))
255@@ -258,6 +319,34 @@
256 }
257 }
258
259+// CheckAptSources checks that the cloudinit will or won't install the given
260+// source, depending on the value of match.
261+func checkAptSource(c *C, x map[interface{}]interface{}, source struct{ Source, Key string }, match bool) {
262+ sources0 := x["apt_sources"]
263+ if sources0 == nil {
264+ if match {
265+ c.Errorf("cloudinit has no entry for apt_sources")
266+ }
267+ return
268+ }
269+
270+ sources := sources0.([]interface{})
271+
272+ found := false
273+ for _, s0 := range sources {
274+ s := s0.(map[interface{}]interface{})
275+ if s["source"] == source.Source && s["key"] == source.Key {
276+ found = true
277+ }
278+ }
279+ switch {
280+ case match && !found:
281+ c.Errorf("source %q not found in %v", source, sources)
282+ case !match && found:
283+ c.Errorf("%q found but not expected in %v", source, sources)
284+ }
285+}
286+
287 // When mutate is called on a known-good MachineConfig,
288 // there should be an error complaining about the missing
289 // field named by the adjacent err.
290
291=== modified file 'environs/ec2/ec2.go'
292--- environs/ec2/ec2.go 2013-04-05 16:50:25 +0000
293+++ environs/ec2/ec2.go 2013-04-11 02:04:22 +0000
294@@ -285,7 +285,6 @@
295 if !hasCert {
296 return fmt.Errorf("no CA certificate in environment configuration")
297 }
298- mongoURL := environs.MongoURL(e, tools.Series, tools.Arch)
299 inst, err := e.startInstance(&startInstanceParams{
300 machineId: "0",
301 machineNonce: state.BootstrapNonce,
302@@ -300,7 +299,6 @@
303 CACert: caCert,
304 },
305 tools: tools,
306- mongoURL: mongoURL,
307 stateServer: true,
308 config: config,
309 stateServerCert: cert,
310@@ -403,7 +401,6 @@
311 DataDir: "/var/lib/juju",
312 Tools: scfg.tools,
313 MachineNonce: scfg.machineNonce,
314- MongoURL: scfg.mongoURL,
315 MachineId: scfg.machineId,
316 AuthorizedKeys: e.ecfg().AuthorizedKeys(),
317 Config: scfg.config,
318@@ -430,7 +427,6 @@
319 info *state.Info
320 apiInfo *api.Info
321 tools *state.Tools
322- mongoURL string
323 stateServer bool
324 config *config.Config
325 stateServerCert []byte
326
327=== added file 'environs/mongo.go'
328--- environs/mongo.go 1970-01-01 00:00:00 +0000
329+++ environs/mongo.go 2013-04-11 02:04:22 +0000
330@@ -0,0 +1,11 @@
331+package environs
332+
333+import (
334+ "fmt"
335+)
336+
337+// MongoStoragePath returns the path that is used to
338+// retrieve the given version of mongodb in a Storage.
339+func MongoStoragePath(series, architecture string) string {
340+ return fmt.Sprintf("tools/mongo-2.2.0-%s-%s.tgz", series, architecture)
341+}
342
343=== removed file 'environs/mongo.go'
344--- environs/mongo.go 2013-04-04 00:51:30 +0000
345+++ environs/mongo.go 1970-01-01 00:00:00 +0000
346@@ -1,48 +0,0 @@
347-package environs
348-
349-import (
350- "fmt"
351-)
352-
353-// MongoURL figures out from where to retrieve a copy of MongoDB compatible with
354-// the given version from the given environment. The search locations are (in order):
355-// - the environment specific storage
356-// - the public storage
357-// - a "well known" EC2 bucket
358-func MongoURL(env Environ, series, architecture string) string {
359- path := MongoStoragePath(series, architecture)
360- url, err := findMongo(env.Storage(), path)
361- if err == nil {
362- return url
363- }
364- url, err = findMongo(env.PublicStorage(), path)
365- if err == nil {
366- return url
367- }
368- // TODO(thumper): this should at least check that the fallback option
369- // exists before returning it. lp:1164220
370- return fmt.Sprintf("http://juju-dist.s3.amazonaws.com/%s", path)
371-}
372-
373-// Return the URL of a compatible MongoDB (if it exists) from the storage,
374-// for the given series and architecture (in vers).
375-func findMongo(store StorageReader, path string) (string, error) {
376- names, err := store.List(path)
377- if err != nil {
378- return "", err
379- }
380- if len(names) != 1 {
381- return "", &NotFoundError{fmt.Errorf("%s not found", path)}
382- }
383- url, err := store.URL(names[0])
384- if err != nil {
385- return "", err
386- }
387- return url, nil
388-}
389-
390-// MongoStoragePath returns the path that is used to
391-// retrieve the given version of mongodb in a Storage.
392-func MongoStoragePath(series, architecture string) string {
393- return fmt.Sprintf("tools/mongo-2.2.0-%s-%s.tgz", series, architecture)
394-}
395
396=== modified file 'environs/mongo_test.go'
397--- environs/mongo_test.go 2013-04-03 21:17:19 +0000
398+++ environs/mongo_test.go 2013-04-11 02:04:22 +0000
399@@ -69,19 +69,3 @@
400 urlpart: "http://juju-dist.s3.amazonaws.com",
401 },
402 }
403-
404-func (t *MongoToolsSuite) TestMongoURL(c *C) {
405- for i, tt := range mongoURLTests {
406- c.Logf("Test %d: %s", i, tt.summary)
407- putNames(c, t.env, tt.contents, tt.publicContents)
408- mongoURL := environs.MongoURL(t.env, version.CurrentSeries(), version.CurrentArch())
409- if tt.expect != "" {
410- assertURLContents(c, mongoURL, tt.expect)
411- }
412- if tt.urlpart != "" {
413- c.Assert(mongoURL, Matches, tt.urlpart+".*")
414- }
415- t.env.Destroy(nil)
416- dummy.ResetPublicStorage(t.env)
417- }
418-}
419
420=== modified file 'environs/openstack/provider.go'
421--- environs/openstack/provider.go 2013-04-05 16:50:25 +0000
422+++ environs/openstack/provider.go 2013-04-11 02:04:22 +0000
423@@ -465,7 +465,6 @@
424 if !hasCert {
425 return fmt.Errorf("no CA certificate in environment configuration")
426 }
427- mongoURL := environs.MongoURL(e, tools.Series, tools.Arch)
428 inst, err := e.startInstance(&startInstanceParams{
429 machineId: "0",
430 machineNonce: state.BootstrapNonce,
431@@ -479,7 +478,6 @@
432 CACert: caCert,
433 },
434 tools: tools,
435- mongoURL: mongoURL,
436 stateServer: true,
437 config: config,
438 constraints: cons,
439@@ -649,7 +647,6 @@
440 info *state.Info
441 apiInfo *api.Info
442 tools *state.Tools
443- mongoURL string
444 stateServer bool
445 config *config.Config
446 constraints constraints.Value
447@@ -673,7 +670,6 @@
448 DataDir: "/var/lib/juju",
449 Tools: scfg.tools,
450 MachineNonce: scfg.machineNonce,
451- MongoURL: scfg.mongoURL,
452 MachineId: scfg.machineId,
453 AuthorizedKeys: e.ecfg().AuthorizedKeys(),
454 Config: scfg.config,

Subscribers

People subscribed via source and target branches