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

Golang common.DestroyEnvironment函数代码示例

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

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



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

示例1: TestDestroyEnvironmentManual

func (s *destroyEnvironmentSuite) TestDestroyEnvironmentManual(c *gc.C) {
	_, nonManager := s.setUpManual(c)

	// If there are any non-manager manual machines in state, DestroyEnvironment will
	// error. It will not set the Dying flag on the environment.
	err := common.DestroyEnvironment(s.State, s.State.EnvironTag())
	c.Assert(err, gc.ErrorMatches, fmt.Sprintf("failed to destroy environment: manually provisioned machines must first be destroyed with `juju destroy-machine %s`", nonManager.Id()))
	env, err := s.State.Environment()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(env.Life(), gc.Equals, state.Alive)

	// If we remove the non-manager machine, it should pass.
	// Manager machines will remain.
	err = nonManager.EnsureDead()
	c.Assert(err, jc.ErrorIsNil)
	err = nonManager.Remove()
	c.Assert(err, jc.ErrorIsNil)
	err = common.DestroyEnvironment(s.State, s.State.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)
	err = env.Refresh()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(env.Life(), gc.Equals, state.Dying)

	s.metricSender.CheckCalls(c, []jtesting.StubCall{{FuncName: "SendMetrics"}})
}
开发者ID:kakamessi99,项目名称:juju,代码行数:25,代码来源:environdestroy_test.go


示例2: TestDestroyStateServerAfterNonStateServerIsDestroyed

func (s *destroyTwoEnvironmentsSuite) TestDestroyStateServerAfterNonStateServerIsDestroyed(c *gc.C) {
	err := common.DestroyEnvironment(s.State, s.State.EnvironTag())
	c.Assert(err, gc.ErrorMatches, "failed to destroy environment: hosting 1 other environments")
	err = common.DestroyEnvironment(s.State, s.otherState.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)
	err = common.DestroyEnvironment(s.State, s.State.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:frankban,项目名称:juju-tmp,代码行数:8,代码来源:environdestroy_test.go


示例3: TestDestroyStateServerAfterNonStateServerIsDestroyed

func (s *destroyTwoEnvironmentsSuite) TestDestroyStateServerAfterNonStateServerIsDestroyed(c *gc.C) {
	err := common.DestroyEnvironment(s.State, s.State.EnvironTag())
	c.Assert(err, gc.ErrorMatches, "failed to destroy environment: hosting 1 other environments")
	err = common.DestroyEnvironment(s.State, s.otherState.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)
	err = common.DestroyEnvironment(s.State, s.State.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)
	s.metricSender.CheckCalls(c, []jtesting.StubCall{{FuncName: "SendMetrics"}, {FuncName: "SendMetrics"}})
}
开发者ID:kakamessi99,项目名称:juju,代码行数:9,代码来源:environdestroy_test.go


示例4: TestCanDestroyNonBlockedEnv

func (s *destroyTwoEnvironmentsSuite) TestCanDestroyNonBlockedEnv(c *gc.C) {
	bh := commontesting.NewBlockHelper(s.APIState)
	defer bh.Close()

	bh.BlockDestroyEnvironment(c, "TestBlockDestroyDestroyEnvironment")

	err := common.DestroyEnvironment(s.State, s.otherState.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)

	err = common.DestroyEnvironment(s.State, s.State.EnvironTag())
	bh.AssertBlocked(c, err, "TestBlockDestroyDestroyEnvironment")
}
开发者ID:frankban,项目名称:juju-tmp,代码行数:12,代码来源:environdestroy_test.go


示例5: DestroySystem

// DestroySystem will attempt to destroy the system. If the args specify the
// removal of blocks or the destruction of the environments, this method will
// attempt to do so.
func (s *SystemManagerAPI) DestroySystem(args params.DestroySystemArgs) error {
	// Get list of all environments in the system.
	allEnvs, err := s.state.AllEnvironments()
	if err != nil {
		return errors.Trace(err)
	}

	// If there are hosted environments and DestroyEnvironments was not
	// specified, don't bother trying to destroy the system, as it will fail.
	if len(allEnvs) > 1 && !args.DestroyEnvironments {
		return errors.Errorf("state server environment cannot be destroyed before all other environments are destroyed")
	}

	// If there are blocks, and we aren't being told to ignore them, let the
	// user know.
	blocks, err := s.state.AllBlocksForSystem()
	if err != nil {
		logger.Debugf("Unable to get blocks for system: %s", err)
		if !args.IgnoreBlocks {
			return errors.Trace(err)
		}
	}
	if len(blocks) > 0 {
		if !args.IgnoreBlocks {
			return common.ErrOperationBlocked("found blocks in system environments")
		}

		err := s.state.RemoveAllBlocksForSystem()
		if err != nil {
			return errors.Trace(err)
		}
	}

	systemEnv, err := s.state.StateServerEnvironment()
	if err != nil {
		return errors.Trace(err)
	}
	systemTag := systemEnv.EnvironTag()

	if args.DestroyEnvironments {
		for _, env := range allEnvs {
			environTag := env.EnvironTag()
			if environTag != systemTag {
				if err := common.DestroyEnvironment(s.state, environTag); err != nil {
					logger.Errorf("unable to destroy environment %q: %s", env.UUID(), err)
				}
			}
		}
	}

	return errors.Trace(common.DestroyEnvironment(s.state, systemTag))
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:55,代码来源:systemmanager.go


示例6: TestCanDestroyNonBlockedEnv

func (s *destroyTwoEnvironmentsSuite) TestCanDestroyNonBlockedEnv(c *gc.C) {
	bh := commontesting.NewBlockHelper(s.APIState)
	defer bh.Close()

	bh.BlockDestroyEnvironment(c, "TestBlockDestroyDestroyEnvironment")

	err := common.DestroyEnvironment(s.State, s.otherState.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)

	err = common.DestroyEnvironment(s.State, s.State.EnvironTag())
	bh.AssertBlocked(c, err, "TestBlockDestroyDestroyEnvironment")

	s.metricSender.CheckCalls(c, []jtesting.StubCall{{FuncName: "SendMetrics"}})
}
开发者ID:kakamessi99,项目名称:juju,代码行数:14,代码来源:environdestroy_test.go


示例7: TestBlockRemoveDestroyEnvironment

func (s *destroyEnvironmentSuite) TestBlockRemoveDestroyEnvironment(c *gc.C) {
	// Setup environment
	s.setUpInstances(c)
	s.BlockRemoveObject(c, "TestBlockRemoveDestroyEnvironment")
	err := common.DestroyEnvironment(s.State, s.State.EnvironTag())
	s.AssertBlocked(c, err, "TestBlockRemoveDestroyEnvironment")
}
开发者ID:frankban,项目名称:juju-tmp,代码行数:7,代码来源:environdestroy_test.go


示例8: TestBlockChangesDestroyEnvironment

func (s *destroyEnvironmentSuite) TestBlockChangesDestroyEnvironment(c *gc.C) {
	// Setup environment
	s.setUpInstances(c)
	// lock environment: can't destroy locked environment
	s.BlockAllChanges(c, "TestBlockChangesDestroyEnvironment")
	err := common.DestroyEnvironment(s.State, s.State.EnvironTag())
	s.AssertBlocked(c, err, "TestBlockChangesDestroyEnvironment")
}
开发者ID:frankban,项目名称:juju-tmp,代码行数:8,代码来源:environdestroy_test.go


示例9: TestBlockRemoveDestroyEnvironment

func (s *destroyEnvironmentSuite) TestBlockRemoveDestroyEnvironment(c *gc.C) {
	// Setup environment
	s.setUpInstances(c)
	s.BlockRemoveObject(c, "TestBlockRemoveDestroyEnvironment")
	err := common.DestroyEnvironment(s.State, s.State.EnvironTag())
	s.AssertBlocked(c, err, "TestBlockRemoveDestroyEnvironment")
	s.metricSender.CheckCalls(c, []jtesting.StubCall{})
}
开发者ID:kakamessi99,项目名称:juju,代码行数:8,代码来源:environdestroy_test.go


示例10: DestroyEnvironment

// DestroyEnvironment will try to destroy the current environment.
// If there is a block on destruction, this method will return an error.
func (c *Client) DestroyEnvironment() (err error) {
	if err := c.check.DestroyAllowed(); err != nil {
		return errors.Trace(err)
	}

	environTag := c.api.state.EnvironTag()
	return errors.Trace(common.DestroyEnvironment(c.api.state, environTag))
}
开发者ID:mhilton,项目名称:juju,代码行数:10,代码来源:client.go


示例11: TestMetrics

func (s *destroyEnvironmentSuite) TestMetrics(c *gc.C) {
	metricSender := &testMetricSender{}
	s.PatchValue(common.SendMetrics, metricSender.SendMetrics)

	err := common.DestroyEnvironment(s.State, s.State.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)

	metricSender.CheckCalls(c, []jtesting.StubCall{{FuncName: "SendMetrics"}})
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:environdestroy_test.go


示例12: TestBlockChangesDestroyEnvironment

func (s *destroyEnvironmentSuite) TestBlockChangesDestroyEnvironment(c *gc.C) {
	// Setup environment
	s.setUpInstances(c)
	// lock environment: can't destroy locked environment
	s.BlockAllChanges(c, "TestBlockChangesDestroyEnvironment")
	err := common.DestroyEnvironment(s.State, s.State.EnvironTag())
	s.AssertBlocked(c, err, "TestBlockChangesDestroyEnvironment")
	s.metricSender.CheckCalls(c, []jtesting.StubCall{})
}
开发者ID:kakamessi99,项目名称:juju,代码行数:9,代码来源:environdestroy_test.go


示例13: TestDestroySystemNoHostedEnvs

func (s *destroySystemSuite) TestDestroySystemNoHostedEnvs(c *gc.C) {
	err := common.DestroyEnvironment(s.State, s.otherState.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)

	err = s.systemManager.DestroySystem(params.DestroySystemArgs{})
	c.Assert(err, jc.ErrorIsNil)

	env, err := s.State.Environment()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(env.Life(), gc.Equals, state.Dying)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:11,代码来源:destroy_test.go


示例14: TestDestroyControllerErrsOnNoHostedEnvsWithBlock

func (s *destroyControllerSuite) TestDestroyControllerErrsOnNoHostedEnvsWithBlock(c *gc.C) {
	err := common.DestroyEnvironment(s.State, s.otherState.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)

	s.BlockDestroyEnvironment(c, "TestBlockDestroyEnvironment")
	s.BlockRemoveObject(c, "TestBlockRemoveObject")

	err = s.controller.DestroyController(params.DestroyControllerArgs{})
	c.Assert(err, gc.ErrorMatches, "found blocks in controller environments")
	env, err := s.State.Environment()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(env.Life(), gc.Equals, state.Alive)
}
开发者ID:imoapps,项目名称:juju,代码行数:13,代码来源:destroy_test.go


示例15: TestDestroySystemNoHostedEnvsWithBlockFail

func (s *destroySystemSuite) TestDestroySystemNoHostedEnvsWithBlockFail(c *gc.C) {
	err := common.DestroyEnvironment(s.State, s.otherState.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)

	s.BlockDestroyEnvironment(c, "TestBlockDestroyEnvironment")
	s.BlockRemoveObject(c, "TestBlockRemoveObject")

	err = s.systemManager.DestroySystem(params.DestroySystemArgs{})
	c.Assert(params.IsCodeOperationBlocked(err), jc.IsTrue)

	numBlocks, err := s.State.AllBlocksForSystem()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(len(numBlocks), gc.Equals, 2)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:14,代码来源:destroy_test.go


示例16: TestDestroyStateServerAfterNonStateServerIsDestroyed

func (s *destroyTwoEnvironmentsSuite) TestDestroyStateServerAfterNonStateServerIsDestroyed(c *gc.C) {
	otherFactory := factory.NewFactory(s.otherState)
	otherFactory.MakeMachine(c, nil)
	m := otherFactory.MakeMachine(c, nil)
	otherFactory.MakeMachineNested(c, m.Id(), nil)

	err := common.DestroyEnvironment(s.State, s.State.EnvironTag())
	c.Assert(err, gc.ErrorMatches, "failed to destroy environment: hosting 1 other environments")

	needsCleanup, err := s.State.NeedsCleanup()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(needsCleanup, jc.IsFalse)

	err = common.DestroyEnvironment(s.State, s.otherState.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)

	err = common.DestroyEnvironment(s.State, s.State.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)

	// Make sure we can continue to take the hosted environ down while the
	// controller environ is dying.
	runAllCleanups(c, s.otherState)
	assertAllMachinesDeadAndRemove(c, s.otherState)
	c.Assert(s.otherState.ProcessDyingEnviron(), jc.ErrorIsNil)

	otherEnv, err := s.otherState.Environment()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(otherEnv.Life(), gc.Equals, state.Dead)

	env, err := s.State.Environment()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(env.Life(), gc.Equals, state.Dying)
	c.Assert(s.State.ProcessDyingEnviron(), jc.ErrorIsNil)
	c.Assert(env.Refresh(), jc.ErrorIsNil)
	c.Assert(env.Life(), gc.Equals, state.Dead)
}
开发者ID:imoapps,项目名称:juju,代码行数:36,代码来源:environdestroy_test.go


示例17: TestCleanupEnvironDocs

func (s *destroyTwoEnvironmentsSuite) TestCleanupEnvironDocs(c *gc.C) {
	otherFactory := factory.NewFactory(s.otherState)
	otherFactory.MakeMachine(c, nil)
	m := otherFactory.MakeMachine(c, nil)
	otherFactory.MakeMachineNested(c, m.Id(), nil)

	err := common.DestroyEnvironment(s.otherState, s.otherState.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)

	_, err = s.otherState.Environment()
	c.Assert(errors.IsNotFound(err), jc.IsTrue)

	_, err = s.State.Environment()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(s.otherState.EnsureEnvironmentRemoved(), jc.ErrorIsNil)
}
开发者ID:frankban,项目名称:juju-tmp,代码行数:16,代码来源:environdestroy_test.go


示例18: TestDestroySystemNoHostedEnvsWithBlock

func (s *destroySystemSuite) TestDestroySystemNoHostedEnvsWithBlock(c *gc.C) {
	err := common.DestroyEnvironment(s.State, s.otherState.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)

	s.BlockDestroyEnvironment(c, "TestBlockDestroyEnvironment")
	s.BlockRemoveObject(c, "TestBlockRemoveObject")

	err = s.systemManager.DestroySystem(params.DestroySystemArgs{
		IgnoreBlocks: true,
	})
	c.Assert(err, jc.ErrorIsNil)

	env, err := s.State.Environment()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(env.Life(), gc.Equals, state.Dying)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:16,代码来源:destroy_test.go


示例19: TestDestroyEnvironmentWithContainers

func (s *destroyEnvironmentSuite) TestDestroyEnvironmentWithContainers(c *gc.C) {
	ops := make(chan dummy.Operation, 500)
	dummy.Listen(ops)

	_, nonManager, _ := s.setUpInstances(c)
	nonManagerId, _ := nonManager.InstanceId()

	err := common.DestroyEnvironment(s.State, s.State.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)
	for op := range ops {
		if op, ok := op.(dummy.OpStopInstances); ok {
			c.Assert(op.Ids, jc.SameContents, []instance.Id{nonManagerId})
			break
		}
	}
}
开发者ID:frankban,项目名称:juju-tmp,代码行数:16,代码来源:environdestroy_test.go


示例20: TestCleanupEnvironDocs

func (s *destroyTwoEnvironmentsSuite) TestCleanupEnvironDocs(c *gc.C) {
	otherFactory := factory.NewFactory(s.otherState)
	otherFactory.MakeMachine(c, nil)
	m := otherFactory.MakeMachine(c, nil)
	otherFactory.MakeMachineNested(c, m.Id(), nil)

	err := common.DestroyEnvironment(s.otherState, s.otherState.EnvironTag())
	c.Assert(err, jc.ErrorIsNil)

	_, err = s.otherState.Environment()
	c.Assert(errors.IsNotFound(err), jc.IsTrue)

	_, err = s.State.Environment()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(s.otherState.EnsureEnvironmentRemoved(), jc.ErrorIsNil)
	s.metricSender.CheckCalls(c, []jtesting.StubCall{{FuncName: "SendMetrics"}})
}
开发者ID:kakamessi99,项目名称:juju,代码行数:17,代码来源:environdestroy_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang common.DestroyModel函数代码示例发布时间:2022-05-23
下一篇:
Golang common.AuthEither函数代码示例发布时间: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