func (s *personalCloudSuite) TestReadUserSpecifiedClouds(c *gc.C) {
	file := osenv.JujuXDGDataHomePath("somemoreclouds.yaml")
	s.setupReadClouds(c, file)
	clouds, err := cloud.ParseCloudMetadataFile(file)
	c.Assert(err, jc.ErrorIsNil)
	s.assertPersonalClouds(c, clouds)
}
Beispiel #2
0
Datei: add.go Projekt: makyo/juju
func (c *addCloudCommand) Run(ctxt *cmd.Context) error {
	specifiedClouds, err := cloud.ParseCloudMetadataFile(c.CloudFile)
	if err != nil {
		return err
	}
	if specifiedClouds == nil {
		return errors.New("no personal clouds are defined")
	}
	newCloud, ok := specifiedClouds[c.Cloud]
	if !ok {
		return errors.Errorf("cloud %q not found in file %q", c.Cloud, c.CloudFile)
	}
	personalClouds, err := cloud.PersonalCloudMetadata()
	if err != nil {
		return err
	}
	if _, ok = personalClouds[c.Cloud]; ok && !c.Replace {
		return errors.Errorf("cloud called %q already exists; use --replace to replace this existing cloud", c.Cloud)
	}
	if personalClouds == nil {
		personalClouds = make(map[string]cloud.Cloud)
	}
	personalClouds[c.Cloud] = newCloud
	return cloud.WritePersonalCloudMetadata(personalClouds)
}
Beispiel #3
0
Datei: add.go Projekt: bac/juju
func (c *addCloudCommand) Run(ctxt *cmd.Context) error {
	specifiedClouds, err := cloud.ParseCloudMetadataFile(c.CloudFile)
	if err != nil {
		return err
	}
	if specifiedClouds == nil {
		return errors.New("no personal clouds are defined")
	}
	newCloud, ok := specifiedClouds[c.Cloud]
	if !ok {
		return errors.Errorf("cloud %q not found in file %q", c.Cloud, c.CloudFile)
	}
	publicClouds, _, err := cloud.PublicCloudMetadata()
	if err != nil {
		return err
	}
	if _, ok = publicClouds[c.Cloud]; ok && !c.Replace {
		return errors.Errorf("%q is the name of a public cloud; use --replace to use your cloud definition instead", c.Cloud)
	}
	builtinClouds := common.BuiltInClouds()
	if _, ok = builtinClouds[c.Cloud]; ok && !c.Replace {
		return errors.Errorf("%q is the name of a built-in cloud; use --replace to use your cloud definition instead", c.Cloud)
	}
	personalClouds, err := cloud.PersonalCloudMetadata()
	if err != nil {
		return err
	}
	if _, ok = personalClouds[c.Cloud]; ok && !c.Replace {
		return errors.Errorf("%q already exists; use --replace to replace this existing cloud", c.Cloud)
	}
	if personalClouds == nil {
		personalClouds = make(map[string]cloud.Cloud)
	}
	personalClouds[c.Cloud] = newCloud
	return cloud.WritePersonalCloudMetadata(personalClouds)
}