当前位置: 首页>>代码示例>>Golang>>正文


Golang registry.RegisterEnvironStorageProviders函数代码示例

本文整理汇总了Golang中github.com/juju/juju/storage/provider/registry.RegisterEnvironStorageProviders函数的典型用法代码示例。如果您正苦于以下问题:Golang RegisterEnvironStorageProviders函数的具体用法?Golang RegisterEnvironStorageProviders怎么用?Golang RegisterEnvironStorageProviders使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了RegisterEnvironStorageProviders函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: setupTestStorageSupport

func setupTestStorageSupport(c *gc.C, s *state.State) {
	stsetts := state.NewStateSettings(s)
	poolManager := poolmanager.New(stsetts)
	_, err := poolManager.Create(testPool, provider.LoopProviderType, map[string]interface{}{"it": "works"})
	c.Assert(err, jc.ErrorIsNil)

	registry.RegisterEnvironStorageProviders("dummy", ec2.EBS_ProviderType)
	registry.RegisterEnvironStorageProviders("dummyenv", ec2.EBS_ProviderType)
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:storage_test.go

示例2: TestRegisterEnvironProvidersMultipleCalls

func (s *providerRegistrySuite) TestRegisterEnvironProvidersMultipleCalls(c *gc.C) {
	ptypeFoo := storage.ProviderType("foo")
	ptypeBar := storage.ProviderType("bar")
	registry.RegisterEnvironStorageProviders("ec2", ptypeFoo)
	registry.RegisterEnvironStorageProviders("ec2", ptypeBar)
	registry.RegisterEnvironStorageProviders("ec2", ptypeBar)
	c.Assert(registry.IsProviderSupported("ec2", ptypeFoo), jc.IsTrue)
	c.Assert(registry.IsProviderSupported("ec2", ptypeBar), jc.IsTrue)
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:providerregistry_test.go

示例3: TestIgnoreNoVolumeSupport

func (s *DestroySuite) TestIgnoreNoVolumeSupport(c *gc.C) {
	staticProvider := &dummy.StorageProvider{
		IsDynamic:    true,
		StorageScope: storage.ScopeEnviron,
		SupportsFunc: func(storage.StorageKind) bool {
			return false
		},
	}
	registry.RegisterProvider("filesystem", staticProvider)
	defer registry.RegisterProvider("filesystem", nil)
	registry.RegisterEnvironStorageProviders("anything, really", "filesystem")
	defer registry.ResetEnvironStorageProviders("anything, really")

	env := &mockEnviron{
		config: configGetter(c),
		allInstances: func() ([]instance.Instance, error) {
			return nil, environs.ErrNoInstances
		},
	}
	err := common.Destroy(env)
	c.Assert(err, jc.ErrorIsNil)

	// common.Destroy will ignore storage providers that don't support
	// volumes (until we have persistent filesystems, that is).
	staticProvider.CheckCallNames(c, "Dynamic", "Scope", "Supports")
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:26,代码来源:destroy_test.go

示例4: TestDestroyVolumeErrors

func (s *DestroySuite) TestDestroyVolumeErrors(c *gc.C) {
	volumeSource := &dummy.VolumeSource{
		ListVolumesFunc: func() ([]string, error) {
			return []string{"vol-0", "vol-1", "vol-2"}, nil
		},
		DestroyVolumesFunc: func(ids []string) []error {
			return []error{
				nil,
				errors.New("cannot destroy vol-1"),
				errors.New("cannot destroy vol-2"),
			}
		},
	}

	staticProvider := &dummy.StorageProvider{
		IsDynamic:    true,
		StorageScope: storage.ScopeEnviron,
		VolumeSourceFunc: func(*config.Config, *storage.Config) (storage.VolumeSource, error) {
			return volumeSource, nil
		},
	}
	registry.RegisterProvider("environ", staticProvider)
	defer registry.RegisterProvider("environ", nil)
	registry.RegisterEnvironStorageProviders("anything, really", "environ")
	defer registry.ResetEnvironStorageProviders("anything, really")

	env := &mockEnviron{
		config: configGetter(c),
		allInstances: func() ([]instance.Instance, error) {
			return nil, environs.ErrNoInstances
		},
	}
	err := common.Destroy(env)
	c.Assert(err, gc.ErrorMatches, "destroying storage: destroying volumes: cannot destroy vol-1, cannot destroy vol-2")
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:35,代码来源:destroy_test.go

示例5: TestAssignUnitWithNonDynamicStorageCleanAvailable

func (s *assignCleanSuite) TestAssignUnitWithNonDynamicStorageCleanAvailable(c *gc.C) {
	registry.RegisterProvider("static", &dummy.StorageProvider{
		IsDynamic: false,
	})
	registry.RegisterEnvironStorageProviders("someprovider", "static")
	defer registry.RegisterProvider("static", nil)
	_, unit, _ := s.setupSingleStorage(c, "filesystem", "static")
	storageAttachments, err := s.State.UnitStorageAttachments(unit.UnitTag())
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(storageAttachments, gc.HasLen, 1)

	// Add a clean machine.
	clean, err := s.State.AddMachine("quantal", state.JobHostUnits)
	c.Assert(err, jc.ErrorIsNil)

	// assign the unit to a machine, requesting clean/empty. Since
	// the unit has non dynamic storage instances associated,
	// it will be forced onto a new machine.
	err = s.State.AssignUnit(unit, state.AssignCleanEmpty)
	c.Assert(err, jc.ErrorIsNil)

	// Check the machine on the unit is set.
	machineId, err := unit.AssignedMachineId()
	c.Assert(err, jc.ErrorIsNil)
	// Check that the machine isn't our clean one.
	c.Assert(machineId, gc.Not(gc.Equals), clean.Id())
}
开发者ID:makyo,项目名称:juju,代码行数:27,代码来源:assign_test.go

示例6: TestDestroyEnvironmentWithPersistentVolumesFails

func (s *EnvironSuite) TestDestroyEnvironmentWithPersistentVolumesFails(c *gc.C) {
	// Create a persistent volume.
	// TODO(wallyworld) - consider moving this to factory
	registry.RegisterEnvironStorageProviders("someprovider", ec2.EBS_ProviderType)
	pm := poolmanager.New(state.NewStateSettings(s.State))
	_, err := pm.Create("persistent-block", ec2.EBS_ProviderType, map[string]interface{}{"persistent": "true"})
	c.Assert(err, jc.ErrorIsNil)

	ch := s.AddTestingCharm(c, "storage-block2")
	storage := map[string]state.StorageConstraints{
		"multi1to10": makeStorageCons("persistent-block", 1024, 1),
	}
	service := s.AddTestingServiceWithStorage(c, "storage-block2", ch, storage)
	unit, err := service.AddUnit()
	c.Assert(err, jc.ErrorIsNil)
	err = s.State.AssignUnit(unit, state.AssignCleanEmpty)
	c.Assert(err, jc.ErrorIsNil)

	volume1, err := s.State.StorageInstanceVolume(names.NewStorageTag("multi1to10/0"))
	c.Assert(err, jc.ErrorIsNil)
	volumeInfoSet := state.VolumeInfo{Size: 123, Persistent: true, VolumeId: "vol-ume"}
	err = s.State.SetVolumeInfo(volume1.VolumeTag(), volumeInfoSet)
	c.Assert(err, jc.ErrorIsNil)

	env, err := s.State.Environment()
	c.Assert(err, jc.ErrorIsNil)
	// TODO(wallyworld) when we can destroy/remove volume, ensure env can then be destroyed
	c.Assert(errors.Cause(env.Destroy()), gc.Equals, state.ErrPersistentVolumesExist)
}
开发者ID:Pankov404,项目名称:juju,代码行数:29,代码来源:environ_test.go

示例7: SetUpSuite

func (s *StorageStateSuiteBase) SetUpSuite(c *gc.C) {
	s.ConnSuite.SetUpSuite(c)

	registry.RegisterProvider("environscoped", &dummy.StorageProvider{
		StorageScope: storage.ScopeEnviron,
		IsDynamic:    true,
	})
	registry.RegisterProvider("machinescoped", &dummy.StorageProvider{
		StorageScope: storage.ScopeMachine,
		IsDynamic:    true,
	})
	registry.RegisterProvider("environscoped-block", &dummy.StorageProvider{
		StorageScope: storage.ScopeEnviron,
		SupportsFunc: func(k storage.StorageKind) bool {
			return k == storage.StorageKindBlock
		},
		IsDynamic: true,
	})
	registry.RegisterProvider("static", &dummy.StorageProvider{
		IsDynamic: false,
	})
	registry.RegisterEnvironStorageProviders(
		"someprovider", "environscoped", "machinescoped",
		"environscoped-block", "static",
	)
	s.AddSuiteCleanup(func(c *gc.C) {
		registry.RegisterProvider("environscoped", nil)
		registry.RegisterProvider("machinescoped", nil)
		registry.RegisterProvider("environscoped-block", nil)
		registry.RegisterProvider("static", nil)
	})
}
开发者ID:Pankov404,项目名称:juju,代码行数:32,代码来源:storage_test.go

示例8: setupMachineBoundStorageTests

func setupMachineBoundStorageTests(c *gc.C, st *State) (*Machine, Volume, Filesystem, func() error) {
	registry.RegisterEnvironStorageProviders("someprovider", provider.LoopProviderType, provider.RootfsProviderType)
	// Make an unprovisioned machine with storage for tests to use.
	// TODO(axw) extend testing/factory to allow creating unprovisioned
	// machines.
	m, err := st.AddOneMachine(MachineTemplate{
		Series: "quantal",
		Jobs:   []MachineJob{JobHostUnits},
		Volumes: []MachineVolumeParams{
			{Volume: VolumeParams{Pool: "loop", Size: 2048}},
		},
		Filesystems: []MachineFilesystemParams{
			{Filesystem: FilesystemParams{Pool: "rootfs", Size: 2048}},
		},
	})
	c.Assert(err, jc.ErrorIsNil)

	va, err := m.VolumeAttachments()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(va, gc.HasLen, 1)
	v, err := st.Volume(va[0].Volume())
	c.Assert(err, jc.ErrorIsNil)

	fa, err := st.MachineFilesystemAttachments(m.MachineTag())
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(fa, gc.HasLen, 1)
	f, err := st.Filesystem(fa[0].Filesystem())
	c.Assert(err, jc.ErrorIsNil)

	return m, v, f, m.Destroy
}
开发者ID:pmatulis,项目名称:juju,代码行数:31,代码来源:upgrades_test.go

示例9: init

func init() {
	environs.RegisterProvider(providerType, azureEnvironProvider{})

	// Register the Azure storage provider.
	registry.RegisterProvider(storageProviderType, &azureStorageProvider{})
	registry.RegisterEnvironStorageProviders(providerType, storageProviderType)
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:7,代码来源:init.go

示例10: init

func init() {
	environs.RegisterProvider(providerType, maasEnvironProvider{})

	//Register the MAAS specific storage providers.
	registry.RegisterProvider(maasStorageProviderType, &maasStorageProvider{})

	registry.RegisterEnvironStorageProviders(providerType, maasStorageProviderType)
}
开发者ID:imoapps,项目名称:juju,代码行数:8,代码来源:init.go

示例11: TestWatchMachineStorage

func (s *watcherSuite) TestWatchMachineStorage(c *gc.C) {
	registry.RegisterProvider(
		"envscoped",
		&dummy.StorageProvider{
			StorageScope: storage.ScopeEnviron,
		},
	)
	registry.RegisterEnvironStorageProviders("dummy", "envscoped")
	defer registry.RegisterProvider("envscoped", nil)

	f := factory.NewFactory(s.BackingState)
	f.MakeMachine(c, &factory.MachineParams{
		Volumes: []state.MachineVolumeParams{{
			Volume: state.VolumeParams{
				Pool: "envscoped",
				Size: 1024,
			},
		}},
	})

	var results params.MachineStorageIdsWatchResults
	args := params.Entities{Entities: []params.Entity{{
		Tag: s.State.EnvironTag().String(),
	}}}
	err := s.stateAPI.APICall(
		"StorageProvisioner",
		s.stateAPI.BestFacadeVersion("StorageProvisioner"),
		"", "WatchVolumeAttachments", args, &results)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(results.Results, gc.HasLen, 1)
	result := results.Results[0]
	c.Assert(result.Error, gc.IsNil)

	w := watcher.NewVolumeAttachmentsWatcher(s.stateAPI, result)
	select {
	case changes, ok := <-w.Changes():
		c.Assert(ok, jc.IsTrue)
		c.Assert(changes, jc.SameContents, []params.MachineStorageId{{
			MachineTag:    "machine-1",
			AttachmentTag: "volume-0",
		}})
	case <-time.After(coretesting.LongWait):
		c.Fatalf("timed out waiting for change")
	}
	select {
	case <-w.Changes():
		c.Fatalf("received unexpected change")
	case <-time.After(coretesting.ShortWait):
	}

	statetesting.AssertStop(c, w)
	select {
	case _, ok := <-w.Changes():
		c.Assert(ok, jc.IsFalse)
	case <-time.After(coretesting.LongWait):
		c.Fatalf("timed out waiting for watcher channel to be closed")
	}
}
开发者ID:Pankov404,项目名称:juju,代码行数:58,代码来源:watcher_test.go

示例12: init

func init() {
	// This will only happen in binaries that actually import this provider
	// somewhere. To enable a provider, import it in the "providers/all"
	// package; please do *not* import individual providers anywhere else,
	// except in direct tests for that provider.
	environs.RegisterProvider("cloudsigma", providerInstance)
	environs.RegisterImageDataSourceFunc("cloud sigma image source", getImageSource)
	registry.RegisterEnvironStorageProviders(providerType)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:9,代码来源:provider.go

示例13: TestSupportedEnvironProviders

func (s *providerRegistrySuite) TestSupportedEnvironProviders(c *gc.C) {
	ptypeFoo := storage.ProviderType("foo")
	ptypeBar := storage.ProviderType("bar")
	registry.RegisterEnvironStorageProviders("ec2", ptypeFoo, ptypeBar)
	c.Assert(registry.IsProviderSupported("ec2", ptypeFoo), jc.IsTrue)
	c.Assert(registry.IsProviderSupported("ec2", ptypeBar), jc.IsTrue)
	c.Assert(registry.IsProviderSupported("ec2", storage.ProviderType("foobar")), jc.IsFalse)
	c.Assert(registry.IsProviderSupported("openstack", ptypeBar), jc.IsFalse)
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:providerregistry_test.go

示例14: SetUpTest

func (s *assignCleanSuite) SetUpTest(c *gc.C) {
	c.Logf("assignment policy for this test: %q", s.policy)
	s.ConnSuite.SetUpTest(c)
	wordpress := s.AddTestingService(c, "wordpress", s.AddTestingCharm(c, "wordpress"))
	s.wordpress = wordpress
	pm := poolmanager.New(state.NewStateSettings(s.State))
	_, err := pm.Create("loop-pool", provider.LoopProviderType, map[string]interface{}{})
	c.Assert(err, jc.ErrorIsNil)
	registry.RegisterEnvironStorageProviders("someprovider", provider.LoopProviderType)
}
开发者ID:makyo,项目名称:juju,代码行数:10,代码来源:assign_test.go

示例15: registerStorageProviders

func (s *withoutControllerSuite) registerStorageProviders(c *gc.C, names ...string) {
	types := make([]storage.ProviderType, len(names))
	for i, name := range names {
		types[i] = storage.ProviderType(name)
		if name == "dynamic" {
			s.registerDynamicStorageProvider(c)
		} else if name == "static" {
			s.registerStaticStorageProvider(c)
		} else {
			c.Fatalf("unknown storage provider type: %q, expected static or dynamic", name)
		}
	}
	registry.RegisterEnvironStorageProviders("dummy", types...)
}
开发者ID:makyo,项目名称:juju,代码行数:14,代码来源:provisioninginfo_test.go


注:本文中的github.com/juju/juju/storage/provider/registry.RegisterEnvironStorageProviders函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。