func (s *toolsSuite) TestFindAvailableToolsCompleteNoValidate(c *gc.C) { s.PatchValue(&arch.HostArch, func() string { return arch.AMD64 }) var allTools tools.List for _, series := range series.SupportedSeries() { binary := version.Binary{ Number: version.Current.Number, Series: series, Arch: arch.HostArch(), OS: version.Current.OS, } allTools = append(allTools, &tools.Tools{ Version: binary, URL: "http://testing.invalid/tools.tar.gz", }) } s.PatchValue(bootstrap.FindTools, func(_ environs.Environ, major, minor int, stream string, f tools.Filter) (tools.List, error) { return allTools, nil }) env := newEnviron("foo", useDefaultKeys, nil) availableTools, err := bootstrap.FindAvailableTools(env, nil, nil, false) c.Assert(err, jc.ErrorIsNil) c.Assert(availableTools, gc.HasLen, len(allTools)) c.Assert(env.supportedArchitecturesCount, gc.Equals, 0) }
func NewImageConstraint(params simplestreams.LookupParams) *ImageConstraint { if len(params.Series) == 0 { params.Series = series.SupportedSeries() } if len(params.Arches) == 0 { params.Arches = arch.AllSupportedArches } return &ImageConstraint{LookupParams: params} }
func (s *supportedSeriesSuite) TestSupportedSeries(c *gc.C) { d := c.MkDir() filename := filepath.Join(d, "ubuntu.csv") err := ioutil.WriteFile(filename, []byte(distInfoData), 0644) c.Assert(err, jc.ErrorIsNil) s.PatchValue(series.DistroInfo, filename) expectedSeries := []string{"precise", "quantal", "raring", "saucy"} series := series.SupportedSeries() sort.Strings(series) c.Assert(series, gc.DeepEquals, expectedSeries) }
func (s *BootstrapSuite) testToolsMetadata(c *gc.C, exploded bool) { envtesting.RemoveFakeToolsMetadata(c, s.toolsStorage) _, cmd, err := s.initBootstrapCommand(c, nil, "--env-config", s.b64yamlEnvcfg, "--instance-id", string(s.instanceId)) c.Assert(err, jc.ErrorIsNil) err = cmd.Run(nil) c.Assert(err, jc.ErrorIsNil) // We don't write metadata at bootstrap anymore. simplestreamsMetadata, err := envtools.ReadMetadata(s.toolsStorage, "released") c.Assert(err, jc.ErrorIsNil) c.Assert(simplestreamsMetadata, gc.HasLen, 0) // The tools should have been added to tools storage, and // exploded into each of the supported series of // the same operating system if the tools were uploaded. st, err := state.Open(testing.EnvironmentTag, &mongo.MongoInfo{ Info: mongo.Info{ Addrs: []string{gitjujutesting.MgoServer.Addr()}, CACert: testing.CACert, }, Password: testPasswordHash(), }, mongo.DefaultDialOpts(), environs.NewStatePolicy()) c.Assert(err, jc.ErrorIsNil) defer st.Close() expectedSeries := make(set.Strings) if exploded { for _, ser := range series.SupportedSeries() { os, err := series.GetOSFromSeries(ser) c.Assert(err, jc.ErrorIsNil) hostos, err := series.GetOSFromSeries(version.Current.Series) c.Assert(err, jc.ErrorIsNil) if os == hostos { expectedSeries.Add(ser) } } } else { expectedSeries.Add(series.HostSeries()) } storage, err := st.ToolsStorage() c.Assert(err, jc.ErrorIsNil) defer storage.Close() metadata, err := storage.AllMetadata() c.Assert(err, jc.ErrorIsNil) c.Assert(metadata, gc.HasLen, expectedSeries.Size()) for _, m := range metadata { c.Assert(expectedSeries.Contains(m.Version.Series), jc.IsTrue) } }
func versionSeries(v string) string { if v == "" { return v } for _, s := range series.SupportedSeries() { sv, err := seriesVersion(s) if err != nil { logger.Errorf("cannot determine version for series %v: %v", s, err) } if v == sv { return s } } return v }
// locallyBuildableTools returns the list of tools that // can be built locally, for series of the same OS. func locallyBuildableTools() (buildable coretools.List) { for _, ser := range series.SupportedSeries() { if os, err := series.GetOSFromSeries(ser); err != nil || os != version.Current.OS { continue } binary := version.Binary{ Number: version.Current.Number, Series: ser, Arch: arch.HostArch(), OS: version.Current.OS, } // Increment the build number so we know it's a development build. binary.Build++ buildable = append(buildable, &coretools.Tools{Version: binary}) } return buildable }
func makeToolsConstraint(cloudSpec simplestreams.CloudSpec, stream string, majorVersion, minorVersion int, filter coretools.Filter) (*ToolsConstraint, error) { var toolsConstraint *ToolsConstraint if filter.Number != version.Zero { // A specific tools version is required, however, a general match based on major/minor // version may also have been requested. This is used to ensure any agent version currently // recorded in the environment matches the Juju cli version. // We can short circuit any lookup here by checking the major/minor numbers against // the filter version and exiting early if there is a mismatch. majorMismatch := majorVersion > 0 && majorVersion != filter.Number.Major minorMismacth := minorVersion != -1 && minorVersion != filter.Number.Minor if majorMismatch || minorMismacth { return nil, coretools.ErrNoMatches } toolsConstraint = NewVersionedToolsConstraint(filter.Number, simplestreams.LookupParams{CloudSpec: cloudSpec, Stream: stream}) } else { toolsConstraint = NewGeneralToolsConstraint(majorVersion, minorVersion, simplestreams.LookupParams{CloudSpec: cloudSpec, Stream: stream}) } if filter.Arch != "" { toolsConstraint.Arches = []string{filter.Arch} } else { logger.Tracef("no architecture specified when finding tools, looking for any") toolsConstraint.Arches = arch.AllSupportedArches } // The old tools search allowed finding tools without needing to specify a series. // The simplestreams metadata is keyed off series, so series must be specified in // the search constraint. If no series is specified, we gather all the series from // lucid onwards and add those to the constraint. var seriesToSearch []string if filter.Series != "" { seriesToSearch = []string{filter.Series} } else { seriesToSearch = series.SupportedSeries() logger.Tracef("no series specified when finding tools, looking for %v", seriesToSearch) } toolsConstraint.Series = seriesToSearch return toolsConstraint, nil }
func (s *supportedSeriesWindowsSuite) TestSupportedSeries(c *gc.C) { expectedSeries := []string{ "arch", "centos7", "precise", "quantal", "raring", "saucy", "trusty", "utopic", "vivid", "win10", "win2012", "win2012hv", "win2012hvr2", "win2012r2", "win7", "win8", "win81", } series := series.SupportedSeries() sort.Strings(series) c.Assert(series, gc.DeepEquals, expectedSeries) }