// GetMetadataSourcesWithRetries returns the sources to use when looking for // simplestreams tools metadata. If env implements SupportsCustomSurces, // the sources returned from that method will also be considered. // The sources are configured to use retries according to the value of allowRetry. func GetMetadataSourcesWithRetries(env environs.ConfigGetter, allowRetry bool) ([]simplestreams.DataSource, error) { var sources []simplestreams.DataSource config := env.Config() if userURL, ok := config.ToolsURL(); ok { verify := utils.VerifySSLHostnames if !config.SSLHostnameVerification() { verify = utils.NoVerifySSLHostnames } sources = append(sources, simplestreams.NewURLDataSource("tools-metadata-url", userURL, verify)) } if custom, ok := env.(SupportsCustomSources); ok { customSources, err := custom.GetToolsSources() if err != nil { return nil, err } sources = append(sources, customSources...) } defaultURL, err := ToolsURL(DefaultBaseURL) if err != nil { return nil, err } if defaultURL != "" { sources = append(sources, simplestreams.NewURLDataSource("default simplestreams", defaultURL, utils.VerifySSLHostnames)) } for _, source := range sources { source.SetAllowRetry(allowRetry) } return sources, nil }
// GetMetadataSources returns the sources to use when looking for // simplestreams image id metadata for the given stream. If env implements // SupportsCustomSources, the sources returned from that method will also // be considered. func GetMetadataSources(env environs.ConfigGetter) ([]simplestreams.DataSource, error) { var sources []simplestreams.DataSource config := env.Config() if userURL, ok := config.ImageMetadataURL(); ok { verify := utils.VerifySSLHostnames if !config.SSLHostnameVerification() { verify = utils.NoVerifySSLHostnames } sources = append(sources, simplestreams.NewURLDataSource("image-metadata-url", userURL, verify)) } if custom, ok := env.(SupportsCustomSources); ok { customSources, err := custom.GetImageSources() if err != nil { return nil, err } sources = append(sources, customSources...) } defaultURL, err := ImageMetadataURL(DefaultBaseURL, config.ImageStream()) if err != nil { return nil, err } if defaultURL != "" { sources = append(sources, simplestreams.NewURLDataSource("default cloud images", defaultURL, utils.VerifySSLHostnames)) } return sources, nil }
// FindBootstrapTools returns a ToolsList containing only those tools with // which it would be reasonable to launch an environment's first machine, given the supplied constraints. // If a specific agent version is not requested, all tools matching the current major.minor version are chosen. func FindBootstrapTools(cloudInst environs.ConfigGetter, params BootstrapToolsParams) (list coretools.List, err error) { // Construct a tools filter. cfg := cloudInst.Config() cliVersion := version.Current.Number filter := coretools.Filter{ Series: params.Series, Arch: stringOrEmpty(params.Arch), } if params.Version != nil { // If we already have an explicit agent version set, we're done. filter.Number = *params.Version return bootstrapFindTools(cloudInst, cliVersion.Major, cliVersion.Minor, filter, params.AllowRetry) } if dev := cliVersion.IsDev() || cfg.Development(); !dev { logger.Infof("filtering tools by released version") filter.Released = true } return bootstrapFindTools(cloudInst, cliVersion.Major, cliVersion.Minor, filter, params.AllowRetry) }