Exemple #1
0
// remoteArchiveMetadata returns Juju GUI archive metadata from simplestreams.
func remoteArchiveMetadata() ([]*gui.Metadata, error) {
	source := gui.NewDataSource(common.GUIDataSourceBaseURL())
	allMeta, err := guiFetchMetadata(gui.ReleasedStream, source)
	if err != nil {
		return nil, errors.Annotate(err, "cannot retrieve Juju GUI archive info")
	}
	if len(allMeta) == 0 {
		return nil, errors.New("no available Juju GUI archives found")
	}
	return allMeta, nil
}
func (s *simplestreamsSuite) TestNewDataSource(c *gc.C) {
	source := gui.NewDataSource("https://1.2.3.4/streams")
	c.Assert(source.Description(), gc.Equals, "gui simplestreams")

	url, err := source.URL("/my/path")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(url, gc.Equals, "https://1.2.3.4/streams//my/path")

	c.Assert(source.RequireSigned(), jc.IsTrue)
	c.Assert(source.PublicSigningKey(), gc.Equals, juju.JujuPublicKey)
}
Exemple #3
0
// guiArchive returns information on the GUI archive that will be uploaded
// to the controller. Possible errors in retrieving the GUI archive information
// do not prevent the model to be bootstrapped. If dataSourceBaseURL is
// non-empty, remote GUI archive info is retrieved from simplestreams using it
// as the base URL. The given logProgress function is used to inform users
// about errors or progress in setting up the Juju GUI.
func guiArchive(dataSourceBaseURL string, logProgress func(string)) *coretools.GUIArchive {
	// The environment variable is only used for development purposes.
	path := os.Getenv("JUJU_GUI")
	if path != "" {
		vers, err := guiVersion(path)
		if err != nil {
			logProgress(fmt.Sprintf("Cannot use Juju GUI at %q: %s", path, err))
			return nil
		}
		hash, size, err := hashAndSize(path)
		if err != nil {
			logProgress(fmt.Sprintf("Cannot use Juju GUI at %q: %s", path, err))
			return nil
		}
		logProgress(fmt.Sprintf("Preparing for Juju GUI %s installation from local archive", vers))
		return &coretools.GUIArchive{
			Version: vers,
			URL:     "file://" + filepath.ToSlash(path),
			SHA256:  hash,
			Size:    size,
		}
	}
	// Check if the user requested to bootstrap with no GUI.
	if dataSourceBaseURL == "" {
		logProgress("Juju GUI installation has been disabled")
		return nil
	}
	// Fetch GUI archives info from simplestreams.
	source := gui.NewDataSource(dataSourceBaseURL)
	allMeta, err := guiFetchMetadata(gui.ReleasedStream, source)
	if err != nil {
		logProgress(fmt.Sprintf("Unable to fetch Juju GUI info: %s", err))
		return nil
	}
	if len(allMeta) == 0 {
		logProgress("No available Juju GUI archives found")
		return nil
	}
	// Metadata info are returned in descending version order.
	logProgress(fmt.Sprintf("Preparing for Juju GUI %s release installation", allMeta[0].Version))
	return &coretools.GUIArchive{
		Version: allMeta[0].Version,
		URL:     allMeta[0].FullPath,
		SHA256:  allMeta[0].SHA256,
		Size:    allMeta[0].Size,
	}
}
Exemple #4
0
// makeGUIMetadata creates and return a Juju GUI archive metadata with the
// given version. If fetchError is not empty, trying to fetch the corresponding
// archive will return the given error.
func makeGUIMetadata(c *gc.C, vers, fetchError string) *envgui.Metadata {
	path, hash, size := saveGUIArchive(c, vers)
	metaPath := "/path/to/gui/" + vers
	return &envgui.Metadata{
		Version:  version.MustParse(vers),
		SHA256:   hash,
		Size:     size,
		Path:     metaPath,
		FullPath: "https://1.2.3.4" + metaPath,
		Source: &dataSource{
			DataSource: envgui.NewDataSource("htpps://1.2.3.4"),
			metaPath:   metaPath,
			path:       path,
			fetchError: fetchError,
			c:          c,
		},
	}
}