• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang common.Destroy函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TestIgnoreNoVolumeSupport

func (s *DestroySuite) TestIgnoreNoVolumeSupport(c *gc.C) {
	staticProvider := &dummy.StorageProvider{
		IsDynamic:    true,
		StorageScope: storage.ScopeEnviron,
		SupportsFunc: func(storage.StorageKind) bool {
			return false
		},
	}

	env := &mockEnviron{
		config: configGetter(c),
		allInstances: func() ([]instance.Instance, error) {
			return nil, environs.ErrNoInstances
		},
		storageProviders: storage.StaticProviderRegistry{
			map[storage.ProviderType]storage.Provider{
				"static": staticProvider,
			},
		},
	}
	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:bac,项目名称:juju,代码行数:27,代码来源:destroy_test.go


示例2: Destroy

func (e *Environ) Destroy() error {
	err := common.Destroy(e)
	if err != nil {
		return errors.Trace(err)
	}
	return e.firewaller.DeleteGlobalGroups()
}
开发者ID:makyo,项目名称:juju,代码行数:7,代码来源:provider.go


示例3: 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


示例4: TestSuccess

func (s *DestroySuite) TestSuccess(c *gc.C) {
	s.PatchValue(&jujuversion.Current, testing.FakeVersionNumber)
	stor := newStorage(s, c)
	err := stor.Put("somewhere", strings.NewReader("stuff"), 5)
	c.Assert(err, jc.ErrorIsNil)

	env := &mockEnviron{
		storage: stor,
		allInstances: func() ([]instance.Instance, error) {
			return []instance.Instance{
				&mockInstance{id: "one"},
			}, nil
		},
		stopInstances: func(ids []instance.Id) error {
			c.Assert(ids, gc.HasLen, 1)
			c.Assert(ids[0], gc.Equals, instance.Id("one"))
			return nil
		},
		config: configGetter(c),
	}
	err = common.Destroy(env)
	c.Assert(err, jc.ErrorIsNil)

	// common.Destroy doesn't touch provider/object storage anymore.
	r, err := stor.Get("somewhere")
	c.Assert(err, jc.ErrorIsNil)
	r.Close()
}
开发者ID:bac,项目名称:juju,代码行数:28,代码来源:destroy_test.go


示例5: Destroy

func (e *Environ) Destroy() error {
	err := common.Destroy(e)
	if err != nil {
		return errors.Trace(err)
	}
	// Delete all security groups remaining in the model.
	return e.firewaller.DeleteAllModelGroups()
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:provider.go


示例6: TestCannotGetInstances

func (s *DestroySuite) TestCannotGetInstances(c *gc.C) {
	env := &mockEnviron{
		allInstances: func() ([]instance.Instance, error) {
			return nil, fmt.Errorf("nope")
		},
	}
	err := common.Destroy(env)
	c.Assert(err, gc.ErrorMatches, "nope")
}
开发者ID:klyachin,项目名称:juju,代码行数:9,代码来源:destroy_test.go


示例7: TestCannotTrashStorageWhenNoInstances

func (s *DestroySuite) TestCannotTrashStorageWhenNoInstances(c *gc.C) {
	env := &mockEnviron{
		storage: &mockStorage{removeAllErr: fmt.Errorf("noes!")},
		allInstances: func() ([]instance.Instance, error) {
			return nil, environs.ErrNoInstances
		},
	}
	err := common.Destroy(env)
	c.Assert(err, gc.ErrorMatches, "noes!")
}
开发者ID:klyachin,项目名称:juju,代码行数:10,代码来源:destroy_test.go


示例8: TestSuccessWhenNoInstances

func (s *DestroySuite) TestSuccessWhenNoInstances(c *gc.C) {
	stor := newStorage(s, c)
	err := stor.Put("elsewhere", strings.NewReader("stuff"), 5)
	c.Assert(err, jc.ErrorIsNil)

	env := &mockEnviron{
		storage: stor,
		allInstances: func() ([]instance.Instance, error) {
			return nil, environs.ErrNoInstances
		},
		config: configGetter(c),
	}
	err = common.Destroy(env)
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:15,代码来源:destroy_test.go


示例9: TestSuccessWhenNoInstances

func (s *DestroySuite) TestSuccessWhenNoInstances(c *gc.C) {
	stor := newStorage(s, c)
	err := stor.Put("elsewhere", strings.NewReader("stuff"), 5)
	c.Assert(err, gc.IsNil)

	env := &mockEnviron{
		storage: stor,
		allInstances: func() ([]instance.Instance, error) {
			return nil, environs.ErrNoInstances
		},
	}
	err = common.Destroy(env)
	c.Assert(err, gc.IsNil)
	_, err = stor.Get("elsewhere")
	c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:klyachin,项目名称:juju,代码行数:16,代码来源:destroy_test.go


示例10: Destroy

func (e *Environ) Destroy() error {
	err := common.Destroy(e)
	if err != nil {
		return errors.Trace(err)
	}
	cfg := e.Config()
	if cfg.UUID() == cfg.ControllerUUID() {
		// In case any hosted environment hasn't been cleaned up yet,
		// we also attempt to delete their resources when the controller
		// environment is destroyed.
		if err := e.destroyControllerManagedEnvirons(); err != nil {
			return errors.Annotate(err, "destroying managed environs")
		}
	}
	// Delete all security groups remaining in the model.
	return e.firewaller.DeleteAllGroups()
}
开发者ID:xushiwei,项目名称:juju,代码行数:17,代码来源:provider.go


示例11: TestCannotStopInstances

func (s *DestroySuite) TestCannotStopInstances(c *gc.C) {
	env := &mockEnviron{
		allInstances: func() ([]instance.Instance, error) {
			return []instance.Instance{
				&mockInstance{id: "one"},
				&mockInstance{id: "another"},
			}, nil
		},
		stopInstances: func(ids []instance.Id) error {
			c.Assert(ids, gc.HasLen, 2)
			c.Assert(ids[0], gc.Equals, instance.Id("one"))
			c.Assert(ids[1], gc.Equals, instance.Id("another"))
			return fmt.Errorf("nah")
		},
	}
	err := common.Destroy(env)
	c.Assert(err, gc.ErrorMatches, "nah")
}
开发者ID:klyachin,项目名称:juju,代码行数:18,代码来源:destroy_test.go


示例12: TestCannotTrashStorage

func (s *DestroySuite) TestCannotTrashStorage(c *gc.C) {
	env := &mockEnviron{
		storage: &mockStorage{removeAllErr: fmt.Errorf("noes!")},
		allInstances: func() ([]instance.Instance, error) {
			return []instance.Instance{
				&mockInstance{id: "one"},
				&mockInstance{id: "another"},
			}, nil
		},
		stopInstances: func(ids []instance.Id) error {
			c.Assert(ids, gc.HasLen, 2)
			c.Assert(ids[0], gc.Equals, instance.Id("one"))
			c.Assert(ids[1], gc.Equals, instance.Id("another"))
			return nil
		},
		config: configGetter(c),
	}
	err := common.Destroy(env)
	c.Assert(err, gc.ErrorMatches, "noes!")
}
开发者ID:jiasir,项目名称:juju,代码行数:20,代码来源:destroy_test.go


示例13: TestSuccessWhenStorageErrors

func (s *DestroySuite) TestSuccessWhenStorageErrors(c *gc.C) {
	// common.Destroy doesn't touch provider/object storage anymore,
	// so failing storage should not affect success.
	env := &mockEnviron{
		storage: &mockStorage{removeAllErr: fmt.Errorf("noes!")},
		allInstances: func() ([]instance.Instance, error) {
			return []instance.Instance{
				&mockInstance{id: "one"},
				&mockInstance{id: "another"},
			}, nil
		},
		stopInstances: func(ids []instance.Id) error {
			c.Assert(ids, gc.HasLen, 2)
			c.Assert(ids[0], gc.Equals, instance.Id("one"))
			c.Assert(ids[1], gc.Equals, instance.Id("another"))
			return nil
		},
		config: configGetter(c),
	}
	err := common.Destroy(env)
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:bac,项目名称:juju,代码行数:22,代码来源:destroy_test.go


示例14: TestIgnoreMachineScopedVolumes

func (s *DestroySuite) TestIgnoreMachineScopedVolumes(c *gc.C) {
	staticProvider := &dummy.StorageProvider{
		IsDynamic:    true,
		StorageScope: storage.ScopeMachine,
	}
	registry.RegisterProvider("machine", staticProvider)
	defer registry.RegisterProvider("machine", nil)
	registry.RegisterEnvironStorageProviders("anything, really", "machine")
	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 machine-scoped storage providers.
	staticProvider.CheckCallNames(c, "Dynamic", "Scope")
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:22,代码来源:destroy_test.go


示例15: TestDestroyEnvScopedVolumes

func (s *DestroySuite) TestDestroyEnvScopedVolumes(c *gc.C) {
	volumeSource := &dummy.VolumeSource{
		ListVolumesFunc: func() ([]string, error) {
			return []string{"vol-0", "vol-1", "vol-2"}, nil
		},
		DestroyVolumesFunc: func(ids []string) ([]error, error) {
			return make([]error, len(ids)), nil
		},
	}
	storageProvider := &dummy.StorageProvider{
		IsDynamic:    true,
		StorageScope: storage.ScopeEnviron,
		VolumeSourceFunc: func(*storage.Config) (storage.VolumeSource, error) {
			return volumeSource, nil
		},
	}

	env := &mockEnviron{
		config: configGetter(c),
		allInstances: func() ([]instance.Instance, error) {
			return nil, environs.ErrNoInstances
		},
		storageProviders: storage.StaticProviderRegistry{
			map[storage.ProviderType]storage.Provider{
				"environ": storageProvider,
			},
		},
	}
	err := common.Destroy(env)
	c.Assert(err, jc.ErrorIsNil)

	// common.Destroy will ignore machine-scoped storage providers.
	storageProvider.CheckCallNames(c, "Dynamic", "Scope", "Supports", "VolumeSource")
	volumeSource.CheckCalls(c, []gitjujutesting.StubCall{
		{"ListVolumes", nil},
		{"DestroyVolumes", []interface{}{[]string{"vol-0", "vol-1", "vol-2"}}},
	})
}
开发者ID:bac,项目名称:juju,代码行数:38,代码来源:destroy_test.go


示例16: TestIgnoreMachineScopedVolumes

func (s *DestroySuite) TestIgnoreMachineScopedVolumes(c *gc.C) {
	staticProvider := &dummy.StorageProvider{
		IsDynamic:    true,
		StorageScope: storage.ScopeMachine,
	}

	env := &mockEnviron{
		config: configGetter(c),
		allInstances: func() ([]instance.Instance, error) {
			return nil, environs.ErrNoInstances
		},
		storageProviders: storage.StaticProviderRegistry{
			map[storage.ProviderType]storage.Provider{
				"static": staticProvider,
			},
		},
	}
	err := common.Destroy(env)
	c.Assert(err, jc.ErrorIsNil)

	// common.Destroy will ignore machine-scoped storage providers.
	staticProvider.CheckCallNames(c, "Dynamic", "Scope")
}
开发者ID:bac,项目名称:juju,代码行数:23,代码来源:destroy_test.go


示例17: TestSuccess

func (s *DestroySuite) TestSuccess(c *gc.C) {
	stor := newStorage(s, c)
	err := stor.Put("somewhere", strings.NewReader("stuff"), 5)
	c.Assert(err, gc.IsNil)

	env := &mockEnviron{
		storage: stor,
		allInstances: func() ([]instance.Instance, error) {
			return []instance.Instance{
				&mockInstance{id: "one"},
			}, nil
		},
		stopInstances: func(ids []instance.Id) error {
			c.Assert(ids, gc.HasLen, 1)
			c.Assert(ids[0], gc.Equals, instance.Id("one"))
			return nil
		},
	}
	err = common.Destroy(env)
	c.Assert(err, gc.IsNil)
	_, err = stor.Get("somewhere")
	c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:klyachin,项目名称:juju,代码行数:23,代码来源:destroy_test.go


示例18: 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, error) {
			return []error{
				nil,
				errors.New("cannot destroy vol-1"),
				errors.New("cannot destroy vol-2"),
			}, nil
		},
	}

	storageProvider := &dummy.StorageProvider{
		IsDynamic:    true,
		StorageScope: storage.ScopeEnviron,
		VolumeSourceFunc: func(*storage.Config) (storage.VolumeSource, error) {
			return volumeSource, nil
		},
	}

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


示例19: Destroy

func (env *joyentEnviron) Destroy() error {
	return errors.Trace(common.Destroy(env))
}
开发者ID:makyo,项目名称:juju,代码行数:3,代码来源:environ.go


示例20: Destroy

func (env *joyentEnviron) Destroy() error {
	return common.Destroy(env)
}
开发者ID:klyachin,项目名称:juju,代码行数:3,代码来源:environ.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang common.MachineFullName函数代码示例发布时间:2022-05-23
下一篇:
Golang common.Bootstrap函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap