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


Golang common.DestroyEnvironment函数代码示例

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


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


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