Merge lp:~wallyworld/juju-core/1.18-utopic-support into lp:juju-core/1.18
- 1.18-utopic-support
- Merge into 1.18
Proposed by
Ian Booth
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ian Booth | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 2290 | ||||
Proposed branch: | lp:~wallyworld/juju-core/1.18-utopic-support | ||||
Merge into: | lp:juju-core/1.18 | ||||
Diff against target: |
600 lines (+201/-148) 16 files modified
environs/bootstrap/synctools.go (+2/-2) environs/imagemetadata/generate.go (+2/-1) environs/imagemetadata/simplestreams.go (+3/-2) environs/simplestreams/export_test.go (+0/-11) environs/simplestreams/simplestreams.go (+0/-102) environs/simplestreams/simplestreams_test.go (+0/-21) environs/simplestreams/testing/testing.go (+2/-1) environs/sync/sync.go (+2/-1) environs/tools/simplestreams.go (+3/-2) environs/tools/testing/testing.go (+2/-1) environs/tools/tools.go (+2/-1) testing/constants.go (+0/-3) version/ubuntu/export_test.go (+15/-0) version/ubuntu/package_test.go (+14/-0) version/ubuntu/supportedseries.go (+116/-0) version/ubuntu/supportedseries_test.go (+38/-0) |
||||
To merge this branch: | bzr merge lp:~wallyworld/juju-core/1.18-utopic-support | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+219131@code.launchpad.net |
Commit message
Backport utopic support from trunk, for bug lp:1314686
Description of the change
Backport utopic support from trunk, for bug lp:1314686
To post a comment you must log in.
Revision history for this message
Go Bot (go-bot) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'environs/bootstrap/synctools.go' |
2 | --- environs/bootstrap/synctools.go 2014-05-09 02:43:07 +0000 |
3 | +++ environs/bootstrap/synctools.go 2014-05-12 02:33:11 +0000 |
4 | @@ -9,7 +9,6 @@ |
5 | |
6 | "launchpad.net/juju-core/environs" |
7 | "launchpad.net/juju-core/environs/config" |
8 | - "launchpad.net/juju-core/environs/simplestreams" |
9 | "launchpad.net/juju-core/environs/sync" |
10 | envtools "launchpad.net/juju-core/environs/tools" |
11 | "launchpad.net/juju-core/errors" |
12 | @@ -17,6 +16,7 @@ |
13 | coretools "launchpad.net/juju-core/tools" |
14 | "launchpad.net/juju-core/utils/set" |
15 | "launchpad.net/juju-core/version" |
16 | + "launchpad.net/juju-core/version/ubuntu" |
17 | ) |
18 | |
19 | const noToolsMessage = `Juju cannot bootstrap because no tools are available for your environment. |
20 | @@ -34,7 +34,7 @@ |
21 | logger.Infof("checking that upload is possible") |
22 | // Check the series are valid. |
23 | for _, series := range bootstrapSeries { |
24 | - if _, err := simplestreams.SeriesVersion(series); err != nil { |
25 | + if _, err := ubuntu.SeriesVersion(series); err != nil { |
26 | return err |
27 | } |
28 | } |
29 | |
30 | === modified file 'environs/imagemetadata/generate.go' |
31 | --- environs/imagemetadata/generate.go 2014-03-03 10:10:44 +0000 |
32 | +++ environs/imagemetadata/generate.go 2014-05-12 02:33:11 +0000 |
33 | @@ -12,6 +12,7 @@ |
34 | "launchpad.net/juju-core/environs/simplestreams" |
35 | "launchpad.net/juju-core/environs/storage" |
36 | "launchpad.net/juju-core/errors" |
37 | + "launchpad.net/juju-core/version/ubuntu" |
38 | ) |
39 | |
40 | // MergeAndWriteMetadata reads the existing metadata from storage (if any), |
41 | @@ -23,7 +24,7 @@ |
42 | if err != nil { |
43 | return err |
44 | } |
45 | - seriesVersion, err := simplestreams.SeriesVersion(series) |
46 | + seriesVersion, err := ubuntu.SeriesVersion(series) |
47 | if err != nil { |
48 | return err |
49 | } |
50 | |
51 | === modified file 'environs/imagemetadata/simplestreams.go' |
52 | --- environs/imagemetadata/simplestreams.go 2014-03-20 05:03:57 +0000 |
53 | +++ environs/imagemetadata/simplestreams.go 2014-05-12 02:33:11 +0000 |
54 | @@ -12,6 +12,7 @@ |
55 | |
56 | "launchpad.net/juju-core/environs/simplestreams" |
57 | "launchpad.net/juju-core/juju/arch" |
58 | + "launchpad.net/juju-core/version/ubuntu" |
59 | ) |
60 | |
61 | func init() { |
62 | @@ -99,7 +100,7 @@ |
63 | |
64 | func NewImageConstraint(params simplestreams.LookupParams) *ImageConstraint { |
65 | if len(params.Series) == 0 { |
66 | - params.Series = simplestreams.SupportedSeries() |
67 | + params.Series = ubuntu.SupportedSeries() |
68 | } |
69 | if len(params.Arches) == 0 { |
70 | params.Arches = arch.AllSupportedArches |
71 | @@ -130,7 +131,7 @@ |
72 | ids := make([]string, nrArches*nrSeries) |
73 | for i, arch := range ic.Arches { |
74 | for j, series := range ic.Series { |
75 | - version, err := simplestreams.SeriesVersion(series) |
76 | + version, err := ubuntu.SeriesVersion(series) |
77 | if err != nil { |
78 | return nil, err |
79 | } |
80 | |
81 | === modified file 'environs/simplestreams/export_test.go' |
82 | --- environs/simplestreams/export_test.go 2013-10-10 11:40:54 +0000 |
83 | +++ environs/simplestreams/export_test.go 2014-05-12 02:33:11 +0000 |
84 | @@ -22,14 +22,3 @@ |
85 | func Filter(entries IndexMetadataSlice, match func(*IndexMetadata) bool) IndexMetadataSlice { |
86 | return entries.filter(match) |
87 | } |
88 | - |
89 | -func SetSeriesVersions(value map[string]string) func() { |
90 | - origVersions := seriesVersions |
91 | - origUpdated := updatedseriesVersions |
92 | - seriesVersions = value |
93 | - updatedseriesVersions = false |
94 | - return func() { |
95 | - seriesVersions = origVersions |
96 | - updatedseriesVersions = origUpdated |
97 | - } |
98 | -} |
99 | |
100 | === modified file 'environs/simplestreams/simplestreams.go' |
101 | --- environs/simplestreams/simplestreams.go 2014-03-21 03:27:16 +0000 |
102 | +++ environs/simplestreams/simplestreams.go 2014-05-12 02:33:11 +0000 |
103 | @@ -10,17 +10,13 @@ |
104 | package simplestreams |
105 | |
106 | import ( |
107 | - "bufio" |
108 | "encoding/json" |
109 | "fmt" |
110 | - "io" |
111 | "io/ioutil" |
112 | - "os" |
113 | "path" |
114 | "reflect" |
115 | "sort" |
116 | "strings" |
117 | - "sync" |
118 | |
119 | "github.com/juju/loggo" |
120 | |
121 | @@ -94,104 +90,6 @@ |
122 | return p |
123 | } |
124 | |
125 | -// seriesVersions provides a mapping between Ubuntu series names and version numbers. |
126 | -// The values here are current as of the time of writing. On Ubuntu systems, we update |
127 | -// these values from /usr/share/distro-info/ubuntu.csv to ensure we have the latest values. |
128 | -// On non-Ubuntu systems, these values provide a nice fallback option. |
129 | -// Exported so tests can change the values to ensure the distro-info lookup works. |
130 | -var seriesVersions = map[string]string{ |
131 | - "precise": "12.04", |
132 | - "quantal": "12.10", |
133 | - "raring": "13.04", |
134 | - "saucy": "13.10", |
135 | - "trusty": "14.04", |
136 | -} |
137 | - |
138 | -var ( |
139 | - seriesVersionsMutex sync.Mutex |
140 | - updatedseriesVersions bool |
141 | -) |
142 | - |
143 | -// SeriesVersion returns the version number for the specified Ubuntu series. |
144 | -func SeriesVersion(series string) (string, error) { |
145 | - if series == "" { |
146 | - panic("cannot pass empty series to SeriesVersion()") |
147 | - } |
148 | - seriesVersionsMutex.Lock() |
149 | - defer seriesVersionsMutex.Unlock() |
150 | - if vers, ok := seriesVersions[series]; ok { |
151 | - return vers, nil |
152 | - } |
153 | - updateSeriesVersions() |
154 | - if vers, ok := seriesVersions[series]; ok { |
155 | - return vers, nil |
156 | - } |
157 | - return "", fmt.Errorf("invalid series %q", series) |
158 | -} |
159 | - |
160 | -// Supported series returns the Ubuntu series for which we expect to find metadata. |
161 | -func SupportedSeries() []string { |
162 | - seriesVersionsMutex.Lock() |
163 | - defer seriesVersionsMutex.Unlock() |
164 | - updateSeriesVersions() |
165 | - var series []string |
166 | - for s := range seriesVersions { |
167 | - series = append(series, s) |
168 | - } |
169 | - return series |
170 | -} |
171 | - |
172 | -func updateSeriesVersions() { |
173 | - if !updatedseriesVersions { |
174 | - err := updateDistroInfo() |
175 | - if err != nil { |
176 | - logger.Warningf("failed to update distro info: %v", err) |
177 | - } |
178 | - updatedseriesVersions = true |
179 | - } |
180 | -} |
181 | - |
182 | -// updateDistroInfo updates seriesVersions from /usr/share/distro-info/ubuntu.csv if possible.. |
183 | -func updateDistroInfo() error { |
184 | - // We need to find the series version eg 12.04 from the series eg precise. Use the information found in |
185 | - // /usr/share/distro-info/ubuntu.csv provided by distro-info-data package. |
186 | - f, err := os.Open("/usr/share/distro-info/ubuntu.csv") |
187 | - if err != nil { |
188 | - // On non-Ubuntu systems this file won't exist but that's expected. |
189 | - return nil |
190 | - } |
191 | - defer f.Close() |
192 | - bufRdr := bufio.NewReader(f) |
193 | - // Only find info for precise or later. |
194 | - preciseOrLaterFound := false |
195 | - for { |
196 | - line, err := bufRdr.ReadString('\n') |
197 | - if err == io.EOF { |
198 | - break |
199 | - } |
200 | - if err != nil { |
201 | - return fmt.Errorf("reading distro info file file: %v", err) |
202 | - } |
203 | - // lines are of the form: "12.04 LTS,Precise Pangolin,precise,2011-10-13,2012-04-26,2017-04-26" |
204 | - parts := strings.Split(line, ",") |
205 | - // Ignore any malformed lines. |
206 | - if len(parts) < 3 { |
207 | - continue |
208 | - } |
209 | - series := parts[2] |
210 | - if series == "precise" { |
211 | - preciseOrLaterFound = true |
212 | - } |
213 | - if series != "precise" && !preciseOrLaterFound { |
214 | - continue |
215 | - } |
216 | - // the numeric version may contain a LTS moniker so strip that out. |
217 | - seriesInfo := strings.Split(parts[0], " ") |
218 | - seriesVersions[series] = seriesInfo[0] |
219 | - } |
220 | - return nil |
221 | -} |
222 | - |
223 | // The following structs define the data model used in the JSON metadata files. |
224 | // Not every model attribute is defined here, only the ones we care about. |
225 | // See the doc/README file in lp:simplestreams for more information. |
226 | |
227 | === modified file 'environs/simplestreams/simplestreams_test.go' |
228 | --- environs/simplestreams/simplestreams_test.go 2014-03-21 03:27:16 +0000 |
229 | +++ environs/simplestreams/simplestreams_test.go 2014-05-12 02:33:11 +0000 |
230 | @@ -5,7 +5,6 @@ |
231 | |
232 | import ( |
233 | "bytes" |
234 | - "sort" |
235 | "strings" |
236 | "testing" |
237 | |
238 | @@ -14,7 +13,6 @@ |
239 | |
240 | "launchpad.net/juju-core/environs/simplestreams" |
241 | sstesting "launchpad.net/juju-core/environs/simplestreams/testing" |
242 | - coretesting "launchpad.net/juju-core/testing" |
243 | "launchpad.net/juju-core/utils" |
244 | ) |
245 | |
246 | @@ -403,25 +401,6 @@ |
247 | c.Check(ti.Endpoint, gc.Equals, "https://ec2.us-west-3.amazonaws.com") |
248 | } |
249 | |
250 | -func (s *simplestreamsSuite) TestSeriesVersion(c *gc.C) { |
251 | - cleanup := simplestreams.SetSeriesVersions(make(map[string]string)) |
252 | - defer cleanup() |
253 | - vers, err := simplestreams.SeriesVersion("precise") |
254 | - if err != nil && err.Error() == `invalid series "precise"` { |
255 | - c.Fatalf(`Unable to lookup series "precise", you may need to: apt-get install distro-info`) |
256 | - } |
257 | - c.Assert(err, gc.IsNil) |
258 | - c.Assert(vers, gc.Equals, "12.04") |
259 | -} |
260 | - |
261 | -func (s *simplestreamsSuite) TestSupportedSeries(c *gc.C) { |
262 | - cleanup := simplestreams.SetSeriesVersions(make(map[string]string)) |
263 | - defer cleanup() |
264 | - series := simplestreams.SupportedSeries() |
265 | - sort.Strings(series) |
266 | - c.Assert(series, gc.DeepEquals, coretesting.SupportedSeries) |
267 | -} |
268 | - |
269 | var getMirrorTests = []struct { |
270 | region string |
271 | endpoint string |
272 | |
273 | === modified file 'environs/simplestreams/testing/testing.go' |
274 | --- environs/simplestreams/testing/testing.go 2014-03-21 03:27:16 +0000 |
275 | +++ environs/simplestreams/testing/testing.go 2014-05-12 02:33:11 +0000 |
276 | @@ -14,6 +14,7 @@ |
277 | "launchpad.net/juju-core/environs/jujutest" |
278 | "launchpad.net/juju-core/environs/simplestreams" |
279 | "launchpad.net/juju-core/testing/testbase" |
280 | + "launchpad.net/juju-core/version/ubuntu" |
281 | ) |
282 | |
283 | var PrivateKeyPassphrase = "12345" |
284 | @@ -535,7 +536,7 @@ |
285 | } |
286 | |
287 | func (tc *testConstraint) Ids() ([]string, error) { |
288 | - version, err := simplestreams.SeriesVersion(tc.Series[0]) |
289 | + version, err := ubuntu.SeriesVersion(tc.Series[0]) |
290 | if err != nil { |
291 | return nil, err |
292 | } |
293 | |
294 | === modified file 'environs/sync/sync.go' |
295 | --- environs/sync/sync.go 2014-03-21 03:27:16 +0000 |
296 | +++ environs/sync/sync.go 2014-05-12 02:33:11 +0000 |
297 | @@ -20,6 +20,7 @@ |
298 | coretools "launchpad.net/juju-core/tools" |
299 | "launchpad.net/juju-core/utils" |
300 | "launchpad.net/juju-core/version" |
301 | + "launchpad.net/juju-core/version/ubuntu" |
302 | ) |
303 | |
304 | var logger = loggo.GetLogger("juju.environs.sync") |
305 | @@ -229,7 +230,7 @@ |
306 | } |
307 | logger.Debugf("generating tarballs for %v", series) |
308 | for _, series := range series { |
309 | - _, err := simplestreams.SeriesVersion(series) |
310 | + _, err := ubuntu.SeriesVersion(series) |
311 | if err != nil { |
312 | return err |
313 | } |
314 | |
315 | === modified file 'environs/tools/simplestreams.go' |
316 | --- environs/tools/simplestreams.go 2014-03-12 00:17:01 +0000 |
317 | +++ environs/tools/simplestreams.go 2014-05-12 02:33:11 +0000 |
318 | @@ -23,6 +23,7 @@ |
319 | coretools "launchpad.net/juju-core/tools" |
320 | "launchpad.net/juju-core/utils/set" |
321 | "launchpad.net/juju-core/version" |
322 | + "launchpad.net/juju-core/version/ubuntu" |
323 | ) |
324 | |
325 | func init() { |
326 | @@ -117,7 +118,7 @@ |
327 | func (tc *ToolsConstraint) Ids() ([]string, error) { |
328 | var allIds []string |
329 | for _, series := range tc.Series { |
330 | - version, err := simplestreams.SeriesVersion(series) |
331 | + version, err := ubuntu.SeriesVersion(series) |
332 | if err != nil { |
333 | return nil, err |
334 | } |
335 | @@ -157,7 +158,7 @@ |
336 | } |
337 | |
338 | func (t *ToolsMetadata) productId() (string, error) { |
339 | - seriesVersion, err := simplestreams.SeriesVersion(t.Release) |
340 | + seriesVersion, err := ubuntu.SeriesVersion(t.Release) |
341 | if err != nil { |
342 | return "", err |
343 | } |
344 | |
345 | === modified file 'environs/tools/testing/testing.go' |
346 | --- environs/tools/testing/testing.go 2014-03-13 23:30:56 +0000 |
347 | +++ environs/tools/testing/testing.go 2014-05-12 02:33:11 +0000 |
348 | @@ -25,6 +25,7 @@ |
349 | "launchpad.net/juju-core/utils" |
350 | "launchpad.net/juju-core/utils/set" |
351 | "launchpad.net/juju-core/version" |
352 | + "launchpad.net/juju-core/version/ubuntu" |
353 | ) |
354 | |
355 | // MakeTools creates some fake tools with the given version strings. |
356 | @@ -123,7 +124,7 @@ |
357 | toolsMetadata := item.(*tools.ToolsMetadata) |
358 | toolsMetadataMap[key] = toolsMetadata |
359 | toolsVersions.Add(key) |
360 | - seriesVersion, err := simplestreams.SeriesVersion(toolsMetadata.Release) |
361 | + seriesVersion, err := ubuntu.SeriesVersion(toolsMetadata.Release) |
362 | c.Assert(err, gc.IsNil) |
363 | productId := fmt.Sprintf("com.ubuntu.juju:%s:%s", seriesVersion, toolsMetadata.Arch) |
364 | expectedProductIds.Add(productId) |
365 | |
366 | === modified file 'environs/tools/tools.go' |
367 | --- environs/tools/tools.go 2014-03-17 03:45:21 +0000 |
368 | +++ environs/tools/tools.go 2014-05-12 02:33:11 +0000 |
369 | @@ -14,6 +14,7 @@ |
370 | "launchpad.net/juju-core/juju/arch" |
371 | coretools "launchpad.net/juju-core/tools" |
372 | "launchpad.net/juju-core/version" |
373 | + "launchpad.net/juju-core/version/ubuntu" |
374 | ) |
375 | |
376 | var logger = loggo.GetLogger("juju.environs.tools") |
377 | @@ -54,7 +55,7 @@ |
378 | seriesToSearch = []string{filter.Series} |
379 | } else { |
380 | logger.Debugf("no series specified when finding tools, looking for any") |
381 | - seriesToSearch = simplestreams.SupportedSeries() |
382 | + seriesToSearch = ubuntu.SupportedSeries() |
383 | } |
384 | toolsConstraint.Series = seriesToSearch |
385 | return toolsConstraint, nil |
386 | |
387 | === modified file 'testing/constants.go' |
388 | --- testing/constants.go 2014-04-24 13:56:51 +0000 |
389 | +++ testing/constants.go 2014-05-12 02:33:11 +0000 |
390 | @@ -25,6 +25,3 @@ |
391 | Total: LongWait, |
392 | Delay: ShortWait, |
393 | } |
394 | - |
395 | -// SupportedSeries lists the series known to Juju. |
396 | -var SupportedSeries = []string{"precise", "quantal", "raring", "saucy", "trusty", "utopic"} |
397 | |
398 | === added directory 'version/ubuntu' |
399 | === added file 'version/ubuntu/export_test.go' |
400 | --- version/ubuntu/export_test.go 1970-01-01 00:00:00 +0000 |
401 | +++ version/ubuntu/export_test.go 2014-05-12 02:33:11 +0000 |
402 | @@ -0,0 +1,15 @@ |
403 | +// Copyright 2014 Canonical Ltd. |
404 | +// Licensed under the AGPLv3, see LICENCE file for details. |
405 | + |
406 | +package ubuntu |
407 | + |
408 | +func SetSeriesVersions(value map[string]string) func() { |
409 | + origVersions := seriesVersions |
410 | + origUpdated := updatedseriesVersions |
411 | + seriesVersions = value |
412 | + updatedseriesVersions = false |
413 | + return func() { |
414 | + seriesVersions = origVersions |
415 | + updatedseriesVersions = origUpdated |
416 | + } |
417 | +} |
418 | |
419 | === added file 'version/ubuntu/package_test.go' |
420 | --- version/ubuntu/package_test.go 1970-01-01 00:00:00 +0000 |
421 | +++ version/ubuntu/package_test.go 2014-05-12 02:33:11 +0000 |
422 | @@ -0,0 +1,14 @@ |
423 | +// Copyright 2013 Canonical Ltd. |
424 | +// Licensed under the LGPLv3, see COPYING and COPYING.LESSER file for details. |
425 | + |
426 | +package ubuntu_test |
427 | + |
428 | +import ( |
429 | + "testing" |
430 | + |
431 | + gc "launchpad.net/gocheck" |
432 | +) |
433 | + |
434 | +func Test(t *testing.T) { |
435 | + gc.TestingT(t) |
436 | +} |
437 | |
438 | === added file 'version/ubuntu/supportedseries.go' |
439 | --- version/ubuntu/supportedseries.go 1970-01-01 00:00:00 +0000 |
440 | +++ version/ubuntu/supportedseries.go 2014-05-12 02:33:11 +0000 |
441 | @@ -0,0 +1,116 @@ |
442 | +// Copyright 2014 Canonical Ltd. |
443 | +// Licensed under the AGPLv3, see LICENCE file for details. |
444 | + |
445 | +package ubuntu |
446 | + |
447 | +import ( |
448 | + "bufio" |
449 | + "fmt" |
450 | + "io" |
451 | + "os" |
452 | + "strings" |
453 | + "sync" |
454 | + |
455 | + "github.com/juju/loggo" |
456 | +) |
457 | + |
458 | +var logger = loggo.GetLogger("juju.ubuntu") |
459 | + |
460 | +// seriesVersions provides a mapping between Ubuntu series names and version numbers. |
461 | +// The values here are current as of the time of writing. On Ubuntu systems, we update |
462 | +// these values from /usr/share/distro-info/ubuntu.csv to ensure we have the latest values. |
463 | +// On non-Ubuntu systems, these values provide a nice fallback option. |
464 | +// Exported so tests can change the values to ensure the distro-info lookup works. |
465 | +var seriesVersions = map[string]string{ |
466 | + "precise": "12.04", |
467 | + "quantal": "12.10", |
468 | + "raring": "13.04", |
469 | + "saucy": "13.10", |
470 | + "trusty": "14.04", |
471 | + "utopic": "14.10", |
472 | +} |
473 | + |
474 | +var ( |
475 | + seriesVersionsMutex sync.Mutex |
476 | + updatedseriesVersions bool |
477 | +) |
478 | + |
479 | +// SeriesVersion returns the version number for the specified Ubuntu series. |
480 | +func SeriesVersion(series string) (string, error) { |
481 | + if series == "" { |
482 | + panic("cannot pass empty series to SeriesVersion()") |
483 | + } |
484 | + seriesVersionsMutex.Lock() |
485 | + defer seriesVersionsMutex.Unlock() |
486 | + if vers, ok := seriesVersions[series]; ok { |
487 | + return vers, nil |
488 | + } |
489 | + updateSeriesVersions() |
490 | + if vers, ok := seriesVersions[series]; ok { |
491 | + return vers, nil |
492 | + } |
493 | + return "", fmt.Errorf("invalid series %q", series) |
494 | +} |
495 | + |
496 | +// SupportedSeries returns the Ubuntu series on which we can run Juju workloads. |
497 | +func SupportedSeries() []string { |
498 | + seriesVersionsMutex.Lock() |
499 | + defer seriesVersionsMutex.Unlock() |
500 | + updateSeriesVersions() |
501 | + var series []string |
502 | + for s := range seriesVersions { |
503 | + series = append(series, s) |
504 | + } |
505 | + return series |
506 | +} |
507 | + |
508 | +func updateSeriesVersions() { |
509 | + if !updatedseriesVersions { |
510 | + err := updateDistroInfo() |
511 | + if err != nil { |
512 | + logger.Warningf("failed to update distro info: %v", err) |
513 | + } |
514 | + updatedseriesVersions = true |
515 | + } |
516 | +} |
517 | + |
518 | +// updateDistroInfo updates seriesVersions from /usr/share/distro-info/ubuntu.csv if possible.. |
519 | +func updateDistroInfo() error { |
520 | + // We need to find the series version eg 12.04 from the series eg precise. Use the information found in |
521 | + // /usr/share/distro-info/ubuntu.csv provided by distro-info-data package. |
522 | + f, err := os.Open("/usr/share/distro-info/ubuntu.csv") |
523 | + if err != nil { |
524 | + // On non-Ubuntu systems this file won't exist but that's expected. |
525 | + return nil |
526 | + } |
527 | + defer f.Close() |
528 | + bufRdr := bufio.NewReader(f) |
529 | + // Only find info for precise or later. |
530 | + preciseOrLaterFound := false |
531 | + for { |
532 | + line, err := bufRdr.ReadString('\n') |
533 | + if err == io.EOF { |
534 | + break |
535 | + } |
536 | + if err != nil { |
537 | + return fmt.Errorf("reading distro info file file: %v", err) |
538 | + } |
539 | + // lines are of the form: "12.04 LTS,Precise Pangolin,precise,2011-10-13,2012-04-26,2017-04-26" |
540 | + parts := strings.Split(line, ",") |
541 | + // Ignore any malformed lines. |
542 | + if len(parts) < 3 { |
543 | + continue |
544 | + } |
545 | + series := parts[2] |
546 | + if series == "precise" { |
547 | + preciseOrLaterFound = true |
548 | + } |
549 | + if series != "precise" && !preciseOrLaterFound { |
550 | + continue |
551 | + } |
552 | + // the numeric version may contain a LTS moniker so strip that out. |
553 | + seriesInfo := strings.Split(parts[0], " ") |
554 | + seriesVersions[series] = seriesInfo[0] |
555 | + } |
556 | + return nil |
557 | +} |
558 | |
559 | === added file 'version/ubuntu/supportedseries_test.go' |
560 | --- version/ubuntu/supportedseries_test.go 1970-01-01 00:00:00 +0000 |
561 | +++ version/ubuntu/supportedseries_test.go 2014-05-12 02:33:11 +0000 |
562 | @@ -0,0 +1,38 @@ |
563 | +// Copyright 2013 Canonical Ltd. |
564 | +// Licensed under the AGPLv3, see LICENCE file for details. |
565 | + |
566 | +package ubuntu_test |
567 | + |
568 | +import ( |
569 | + "sort" |
570 | + |
571 | + gc "launchpad.net/gocheck" |
572 | + |
573 | + "launchpad.net/juju-core/testing/testbase" |
574 | + "launchpad.net/juju-core/version/ubuntu" |
575 | +) |
576 | + |
577 | +type simplestreamsSuite struct { |
578 | + testbase.LoggingSuite |
579 | +} |
580 | + |
581 | +var _ = gc.Suite(&simplestreamsSuite{}) |
582 | + |
583 | +func (s *simplestreamsSuite) TestSeriesVersion(c *gc.C) { |
584 | + cleanup := ubuntu.SetSeriesVersions(make(map[string]string)) |
585 | + defer cleanup() |
586 | + vers, err := ubuntu.SeriesVersion("precise") |
587 | + if err != nil && err.Error() == `invalid series "precise"` { |
588 | + c.Fatalf(`Unable to lookup series "precise", you may need to: apt-get install distro-info`) |
589 | + } |
590 | + c.Assert(err, gc.IsNil) |
591 | + c.Assert(vers, gc.Equals, "12.04") |
592 | +} |
593 | + |
594 | +func (s *simplestreamsSuite) TestSupportedSeries(c *gc.C) { |
595 | + cleanup := ubuntu.SetSeriesVersions(make(map[string]string)) |
596 | + defer cleanup() |
597 | + series := ubuntu.SupportedSeries() |
598 | + sort.Strings(series) |
599 | + c.Assert(series, gc.DeepEquals, []string{"precise", "quantal", "raring", "saucy", "trusty", "utopic"}) |
600 | +} |
The attempt to merge lp:~wallyworld/juju-core/1.18-utopic-support into lp:juju-core/1.18 failed. Below is the output from the failed tests.
ok launchpad. net/juju- core 0.013s net/juju- core/agent 1.181s net/juju- core/agent/ mongo 0.635s net/juju- core/agent/ tools 0.175s net/juju- core/bzr 4.872s net/juju- core/cert 2.644s net/juju- core/charm 0.348s net/juju- core/charm/ hooks [no test files] net/juju- core/charm/ testing [no test files] net/juju- core/cloudinit 0.027s net/juju- core/cloudinit/ sshinit 0.794s net/juju- core/cmd 0.172s net/juju- core/cmd/ charm-admin 0.724s net/juju- core/cmd/ charmd [no test files] net/juju- core/cmd/ charmload [no test files] net/juju- core/cmd/ envcmd 0.215s net/juju- core/cmd/ juju 203.203s net/juju- core/cmd/ jujud 64.292s net/juju- core/cmd/ plugins/ juju-metadata 9.223s net/juju- core/cmd/ plugins/ juju-restore [no test files] net/juju- core/cmd/ plugins/ local 0.195s net/juju- core/cmd/ plugins/ local/juju- local [no test files] net/juju- core/constraint s 0.018s net/juju- core/container 0.038s net/juju- core/container/ factory 0.049s net/juju- core/container/ kvm 0.238s net/juju- core/container/ kvm/mock 0.049s net/juju- core/container/ kvm/testing [no test files] net/juju- core/container/ lxc 4.320s net/juju- core/container/ lxc/mock [no test files] net/juju- core/container/ lxc/testing [no test files] net/juju- core/container/ testing [no test files] net/juju- core/downloader 5.243s net/juju- core/environs 2.520s net/juju- core/environs/ bootstrap 10.911s net/juju- core/environs/ cloudinit 0.512s net/juju- core/environs/ config 1.816s net/juju- core/environs/ configstore 0.033s net/juju- core/environs/ filestorage 0.026s net/juju- core/environs/ httpstorage 0.671s net/juju- core/environs/ imagemetadata 0.424s net/juju- core/environs/ imagemetadata/ testing [no test files] net/juju- core/environs/ instances 0.043s net/juju- core/environs/ jujutest 0.161s net/juju- core/environs/ manual 10.539s net/juju- core/environs/ simplestreams 0.290s net/juju- core/environs/ simplestreams/ testing [no test files] net/juju- core/environs/ sshstorage 0.921s net/juju- core/environs/ storage 0.887s net/juju- core/environs/ sync 44.401s net/juju- core/environs/ testing 0.155s net/juju- core/environs/ tools 4.494s net/juju- core/environs/ tools/testing [no test files] net/juju- core/errors 0.010s net/juju- core/instance 0.016s net/juju- core/instance/ testing [no test files] net/juju- core/juju ...
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.