本文整理汇总了Golang中github.com/juju/juju/apiserver/params.IsCodeOperationBlocked函数的典型用法代码示例。如果您正苦于以下问题:Golang IsCodeOperationBlocked函数的具体用法?Golang IsCodeOperationBlocked怎么用?Golang IsCodeOperationBlocked使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsCodeOperationBlocked函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: assertBlocked
func (s *modelconfigSuite) assertBlocked(c *gc.C, err error, msg string) {
c.Assert(params.IsCodeOperationBlocked(err), jc.IsTrue, gc.Commentf("error: %#v", err))
c.Assert(errors.Cause(err), jc.DeepEquals, ¶ms.Error{
Message: msg,
Code: "operation is blocked",
})
}
示例2: ensureUserFriendlyErrorLog
// ensureUserFriendlyErrorLog ensures that error will be logged and displayed
// in a user-friendly manner with readable and digestable error message.
func (c *destroyCommand) ensureUserFriendlyErrorLog(destroyErr error, ctx *cmd.Context, api destroyControllerAPI) error {
if destroyErr == nil {
return nil
}
if params.IsCodeOperationBlocked(destroyErr) {
logger.Errorf(`there are blocks preventing controller destruction
To remove all blocks in the controller, please run:
juju controller remove-blocks
`)
if api != nil {
envs, err := api.ListBlockedEnvironments()
var bytes []byte
if err == nil {
bytes, err = formatTabularBlockedEnvironments(envs)
}
if err != nil {
logger.Errorf("Unable to list blocked environments: %s", err)
return cmd.ErrSilent
}
ctx.Infof(string(bytes))
}
return cmd.ErrSilent
}
logger.Errorf(stdFailureMsg, c.EnvName())
return destroyErr
}
示例3: ensureUserFriendlyErrorLog
// ensureUserFriendlyErrorLog ensures that error will be logged and displayed
// in a user-friendly manner with readable and digestable error message.
func (c *destroyCommand) ensureUserFriendlyErrorLog(destroyErr error, ctx *cmd.Context, api destroyControllerAPI) error {
if destroyErr == nil {
return nil
}
if params.IsCodeOperationBlocked(destroyErr) {
logger.Errorf(destroyControllerBlockedMsg)
if api != nil {
models, err := api.ListBlockedModels()
out := &bytes.Buffer{}
if err == nil {
var info interface{}
info, err = block.FormatModelBlockInfo(models)
if err != nil {
return errors.Trace(err)
}
err = block.FormatTabularBlockedModels(out, info)
}
if err != nil {
logger.Errorf("Unable to list models: %s", err)
return cmd.ErrSilent
}
ctx.Infof(out.String())
}
return cmd.ErrSilent
}
if params.IsCodeHasHostedModels(destroyErr) {
return destroyErr
}
logger.Errorf(stdFailureMsg, c.ControllerName())
return destroyErr
}
示例4: ensureUserFriendlyErrorLog
// ensureUserFriendlyErrorLog ensures that error will be logged and displayed
// in a user-friendly manner with readable and digestable error message.
func (c *destroyCommand) ensureUserFriendlyErrorLog(destroyErr error, ctx *cmd.Context, api destroyControllerAPI) error {
if destroyErr == nil {
return nil
}
if params.IsCodeOperationBlocked(destroyErr) {
logger.Errorf(destroyControllerBlockedMsg)
if api != nil {
models, err := api.ListBlockedModels()
var bytes []byte
if err == nil {
bytes, err = formatTabularBlockedModels(models)
}
if err != nil {
logger.Errorf("Unable to list blocked models: %s", err)
return cmd.ErrSilent
}
ctx.Infof(string(bytes))
}
return cmd.ErrSilent
}
if params.IsCodeHasHostedModels(destroyErr) {
return destroyErr
}
logger.Errorf(stdFailureMsg, c.ControllerName())
return destroyErr
}
示例5: AssertBlocked
func (s *clientSuite) AssertBlocked(c *gc.C, err error, msg string) {
c.Assert(params.IsCodeOperationBlocked(err), jc.IsTrue, gc.Commentf("error: %#v", err))
c.Assert(errors.Cause(err), gc.DeepEquals, &rpc.RequestError{
Message: msg,
Code: "operation is blocked",
})
}
示例6: assertErrorBlocked
func (s *blockCheckerSuite) assertErrorBlocked(c *gc.C, blocked bool, err error, msg string) {
if blocked {
c.Assert(params.IsCodeOperationBlocked(err), jc.IsTrue)
c.Assert(err, gc.ErrorMatches, msg)
} else {
c.Assert(errors.Cause(err), jc.ErrorIsNil)
}
}
示例7: processDestroyError
// processDestroyError determines how to format error message based on its code.
// Note that CodeNotImplemented errors have not be propogated in previous implementation.
// This behaviour was preserved.
func processDestroyError(err error) error {
if err == nil || params.IsCodeNotImplemented(err) {
return nil
}
if params.IsCodeOperationBlocked(err) {
return err
}
return errors.Annotate(err, "destroying environment")
}
示例8: handleError
func (c *destroyCommand) handleError(err error) error {
if err == nil {
return nil
}
if params.IsCodeOperationBlocked(err) {
return block.ProcessBlockedError(err, block.BlockDestroy)
}
logger.Errorf(`failed to destroy environment %q`, c.envName)
return err
}
示例9: handleError
func (c *destroyCommand) handleError(err error, modelName string) error {
if err == nil {
return nil
}
if params.IsCodeOperationBlocked(err) {
return block.ProcessBlockedError(err, block.BlockDestroy)
}
logger.Errorf(`failed to destroy model %q`, modelName)
return err
}
示例10: ProcessBlockedError
// ProcessBlockedError ensures that correct and user-friendly message is
// displayed to the user based on the block type.
func ProcessBlockedError(err error, block Block) error {
if err == nil {
return nil
}
if params.IsCodeOperationBlocked(err) {
logger.Errorf("\n%v%v", err, blockedMessages[block])
return cmd.ErrSilent
}
return err
}
示例11: ensureUserFriendlyErrorLog
// ensureUserFriendlyErrorLog ensures that error will be logged and displayed
// in a user-friendly manner with readable and digestable error message.
func (c *destroyEnvironmentCommand) ensureUserFriendlyErrorLog(err error) error {
if err == nil {
return nil
}
if params.IsCodeOperationBlocked(err) {
return block.ProcessBlockedError(err, block.BlockDestroy)
}
logger.Errorf(stdFailureMsg, c.EnvName())
return err
}
示例12: ProcessBlockedError
// ProcessBlockedError ensures that correct and user-friendly message is
// displayed to the user based on the block type.
func ProcessBlockedError(err error, block Block) error {
if err == nil {
return nil
}
if params.IsCodeOperationBlocked(err) {
msg := blockedMessages[block]
logger.Errorf("%v\n%v", err, msg)
return errors.New(msg)
}
return err
}
示例13: TestDestroyControllerNoHostedEnvsWithBlockFail
func (s *destroyControllerSuite) TestDestroyControllerNoHostedEnvsWithBlockFail(c *gc.C) {
err := common.DestroyModel(s.State, s.otherState.ModelTag())
c.Assert(err, jc.ErrorIsNil)
s.BlockDestroyModel(c, "TestBlockDestroyModel")
s.BlockRemoveObject(c, "TestBlockRemoveObject")
err = s.controller.DestroyController(params.DestroyControllerArgs{})
c.Assert(params.IsCodeOperationBlocked(err), jc.IsTrue)
numBlocks, err := s.State.AllBlocksForController()
c.Assert(err, jc.ErrorIsNil)
c.Assert(len(numBlocks), gc.Equals, 2)
}
示例14: 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)
}
示例15: TestDestroySystemReturnsBlockedEnvironmentsErr
func (s *destroySystemSuite) TestDestroySystemReturnsBlockedEnvironmentsErr(c *gc.C) {
s.BlockDestroyEnvironment(c, "TestBlockDestroyEnvironment")
s.BlockRemoveObject(c, "TestBlockRemoveObject")
s.otherState.SwitchBlockOn(state.DestroyBlock, "TestBlockDestroyEnvironment")
s.otherState.SwitchBlockOn(state.ChangeBlock, "TestChangeBlock")
err := s.systemManager.DestroySystem(params.DestroySystemArgs{
DestroyEnvironments: true,
})
c.Assert(params.IsCodeOperationBlocked(err), jc.IsTrue)
numBlocks, err := s.State.AllBlocksForSystem()
c.Assert(err, jc.ErrorIsNil)
c.Assert(len(numBlocks), gc.Equals, 4)
_, err = s.otherState.Environment()
c.Assert(err, jc.ErrorIsNil)
}