Beispiel #1
0
func destroyStorage(env environs.Environ) error {
	logger.Infof("destroying storage")
	environConfig := env.Config()
	storageProviderTypes, ok := registry.EnvironStorageProviders(environConfig.Type())
	if !ok {
		return nil
	}
	for _, storageProviderType := range storageProviderTypes {
		storageProvider, err := registry.StorageProvider(storageProviderType)
		if err != nil {
			return errors.Trace(err)
		}
		if !storageProvider.Dynamic() {
			continue
		}
		if storageProvider.Scope() != storage.ScopeEnviron {
			continue
		}
		if err := destroyVolumes(environConfig, storageProviderType, storageProvider); err != nil {
			return errors.Trace(err)
		}
		// TODO(axw) destroy env-level filesystems when we have them.
	}
	return nil
}
Beispiel #2
0
func (a *API) allProviders() ([]storage.ProviderType, error) {
	envName, err := a.storage.EnvName()
	if err != nil {
		return nil, errors.Annotate(err, "getting env name")
	}
	if providers, ok := registry.EnvironStorageProviders(envName); ok {
		return providers, nil
	}
	return nil, nil
}
Beispiel #3
0
func (s *providerRegistrySuite) TestListEnvProviderKnownEnv(c *gc.C) {
	ptypeFoo := storage.ProviderType("foo")
	registry.RegisterEnvironStorageProviders("ec2", ptypeFoo)
	all, exists := registry.EnvironStorageProviders("ec2")
	c.Assert(exists, jc.IsTrue)
	c.Assert(len(all) > 0, jc.IsTrue)

	found := false
	for _, one := range all {
		if one == ptypeFoo {
			found = true
			break
		}
	}
	c.Assert(found, jc.IsTrue)
}
Beispiel #4
0
func (s *providerRegistrySuite) TestListEnvProviderUnknownEnv(c *gc.C) {
	all, exists := registry.EnvironStorageProviders("fluffy")
	c.Assert(exists, jc.IsFalse)
	c.Assert(all, gc.IsNil)
}