func (s *supportedSeriesSuite) TestOSSupportedSeries(c *gc.C) { series.SetSeriesVersions(map[string]string{ "trusty": "14.04", "utopic": "14.10", "win7": "win7", "win81": "win81", "centos7": "centos7", "arch": "rolling", }) supported := series.OSSupportedSeries(os.Ubuntu) c.Assert(supported, jc.SameContents, []string{"trusty", "utopic"}) supported = series.OSSupportedSeries(os.Windows) c.Assert(supported, jc.SameContents, []string{"win7", "win81"}) supported = series.OSSupportedSeries(os.CentOS) c.Assert(supported, jc.SameContents, []string{"centos7"}) supported = series.OSSupportedSeries(os.Arch) c.Assert(supported, jc.SameContents, []string{"arch"}) }
// populateTools stores uploaded tools in provider storage // and updates the tools metadata. func (c *BootstrapCommand) populateTools(st *state.State, env environs.Environ) error { agentConfig := c.CurrentConfig() dataDir := agentConfig.DataDir() tools, err := agenttools.ReadTools(dataDir, version.Current) if err != nil { return err } data, err := ioutil.ReadFile(filepath.Join( agenttools.SharedToolsDir(dataDir, version.Current), "tools.tar.gz", )) if err != nil { return err } storage, err := st.ToolsStorage() if err != nil { return err } defer storage.Close() var toolsVersions []version.Binary if strings.HasPrefix(tools.URL, "file://") { // Tools were uploaded: clone for each series of the same OS. osSeries := series.OSSupportedSeries(tools.Version.OS) for _, ser := range osSeries { toolsVersion := tools.Version toolsVersion.Series = ser toolsVersions = append(toolsVersions, toolsVersion) } } else { // Tools were downloaded from an external source: don't clone. toolsVersions = []version.Binary{tools.Version} } for _, toolsVersion := range toolsVersions { metadata := toolstorage.Metadata{ Version: toolsVersion, Size: tools.Size, SHA256: tools.SHA256, } logger.Debugf("Adding tools: %v", toolsVersion) if err := storage.AddTools(bytes.NewReader(data), metadata); err != nil { return err } } return nil }
// uploadTools compiles jujud from $GOPATH and uploads it into the supplied // storage. If no version has been explicitly chosen, the version number // reported by the built tools will be based on the client version number. // In any case, the version number reported will have a build component higher // than that of any otherwise-matching available envtools. // uploadTools resets the chosen version and replaces the available tools // with the ones just uploaded. func (context *upgradeContext) uploadTools() (err error) { // TODO(fwereade): this is kinda crack: we should not assume that // version.Current matches whatever source happens to be built. The // ideal would be: // 1) compile jujud from $GOPATH into some build dir // 2) get actual version with `jujud version` // 3) check actual version for compatibility with CLI tools // 4) generate unique build version with reference to available tools // 5) force-version that unique version into the dir directly // 6) archive and upload the build dir // ...but there's no way we have time for that now. In the meantime, // considering the use cases, this should work well enough; but it // won't detect an incompatible major-version change, which is a shame. if context.chosen == version.Zero { context.chosen = context.client } context.chosen = uploadVersion(context.chosen, context.tools) builtTools, err := sync.BuildToolsTarball(&context.chosen, "upgrade") if err != nil { return err } defer os.RemoveAll(builtTools.Dir) var uploaded *coretools.Tools toolsPath := path.Join(builtTools.Dir, builtTools.StorageName) logger.Infof("uploading tools %v (%dkB) to Juju state server", builtTools.Version, (builtTools.Size+512)/1024) f, err := os.Open(toolsPath) if err != nil { return err } defer f.Close() additionalSeries := series.OSSupportedSeries(builtTools.Version.OS) uploaded, err = context.apiClient.UploadTools(f, builtTools.Version, additionalSeries...) if err != nil { return err } context.tools = coretools.List{uploaded} return nil }