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

Golang common.ErrOperationBlocked函数代码示例

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

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



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

示例1: TestBlockedError

func (s *SetSuite) TestBlockedError(c *gc.C) {
	s.fake.err = common.ErrOperationBlocked("TestBlockedError")
	_, err := s.run(c, "special=extra")
	c.Assert(err, gc.Equals, cmd.ErrSilent)
	// msg is logged
	c.Check(c.GetTestLog(), jc.Contains, "TestBlockedError")
}
开发者ID:Pankov404,项目名称:juju,代码行数:7,代码来源:set_test.go


示例2: TestBlockSetService

func (s *ConstraintsCommandsSuite) TestBlockSetService(c *gc.C) {
	s.fake.addTestingService("svc")

	// Block operation
	s.fake.err = common.ErrOperationBlocked("TestBlockSetService")
	// Set constraints.
	s.assertSetBlocked(c, "-s", "svc", "mem=4G", "cpu-power=250")
}
开发者ID:Pankov404,项目名称:juju,代码行数:8,代码来源:constraints_test.go


示例3: TestBlockedError

func (s *AddMachineSuite) TestBlockedError(c *gc.C) {
	s.fakeAddMachine.addError = common.ErrOperationBlocked("TestBlockedError")
	_, err := s.run(c)
	c.Assert(err, gc.Equals, cmd.ErrSilent)
	// msg is logged
	stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
	c.Check(stripped, gc.Matches, ".*TestBlockedError.*")
}
开发者ID:Pankov404,项目名称:juju,代码行数:8,代码来源:add_test.go


示例4: TestBlockedError

func (s *RemoveMachineSuite) TestBlockedError(c *gc.C) {
	s.fake.removeError = common.ErrOperationBlocked("TestBlockedError")
	_, err := s.run(c, "1")
	c.Assert(err, gc.Equals, cmd.ErrSilent)
	c.Assert(s.fake.forced, jc.IsFalse)
	// msg is logged
	stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
	c.Assert(stripped, gc.Matches, ".*TestBlockedError.*")
}
开发者ID:Pankov404,项目名称:juju,代码行数:9,代码来源:remove_test.go


示例5: TestBlockEnsureAvailability

func (s *EnsureAvailabilitySuite) TestBlockEnsureAvailability(c *gc.C) {
	s.fake.err = common.ErrOperationBlocked("TestBlockEnsureAvailability")
	_, err := s.runEnsureAvailability(c, "-n", "1")
	c.Assert(err, gc.ErrorMatches, cmd.ErrSilent.Error())

	// msg is logged
	stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
	c.Check(stripped, gc.Matches, ".*TestBlockEnsureAvailability.*")
}
开发者ID:Pankov404,项目名称:juju,代码行数:9,代码来源:ensureavailability_test.go


示例6: TestBlockAddUnit

func (s *AddUnitSuite) TestBlockAddUnit(c *gc.C) {
	// Block operation
	s.fake.err = common.ErrOperationBlocked("TestBlockAddUnit")
	s.runAddUnit(c, "some-service-name")

	// msg is logged
	stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
	c.Check(stripped, gc.Matches, ".*TestBlockAddUnit.*")
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:9,代码来源:addunit_test.go


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


示例8: TestBlockUnset

func (s *UnsetSuite) TestBlockUnset(c *gc.C) {
	// Block operation
	s.fake.err = common.ErrOperationBlocked("TestBlockUnset")
	ctx := coretesting.ContextForDir(c, s.dir)
	code := cmd.Main(envcmd.Wrap(service.NewUnsetCommand(s.fake)), ctx, []string{
		"dummy-service",
		"username"})
	c.Check(code, gc.Equals, 1)

	// msg is logged
	stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
	c.Check(stripped, gc.Matches, ".*TestBlockUnset.*")
}
开发者ID:Pankov404,项目名称:juju,代码行数:13,代码来源:unset_test.go


示例9: TestBlockUpgradeInProgress

func (s *UpgradeJujuSuite) TestBlockUpgradeInProgress(c *gc.C) {
	fakeAPI := NewFakeUpgradeJujuAPI(c, s.State)
	fakeAPI.setVersionErr = common.ErrOperationBlocked("The operation has been blocked.")
	fakeAPI.patch(s)
	cmd := &UpgradeJujuCommand{}
	err := coretesting.InitCommand(envcmd.Wrap(cmd), []string{})
	c.Assert(err, jc.ErrorIsNil)

	// Block operation
	s.BlockAllChanges(c, "TestBlockUpgradeInProgress")
	err = cmd.Run(coretesting.Context(c))
	s.AssertBlocked(c, err, ".*To unblock changes.*")
}
开发者ID:kakamessi99,项目名称:juju,代码行数:13,代码来源:upgradejuju_test.go


示例10: AddUser

func (m *mockAddUserAPI) AddUser(username, displayname, password string) (names.UserTag, error) {
	if m.blocked {
		return names.UserTag{}, common.ErrOperationBlocked("The operation has been blocked.")
	}

	m.username = username
	m.displayname = displayname
	m.password = password
	if m.failMessage == "" {
		return names.NewLocalUserTag(username), nil
	}
	return names.UserTag{}, errors.New(m.failMessage)
}
开发者ID:Pankov404,项目名称:juju,代码行数:13,代码来源:add_test.go


示例11: TestBlockRetryProvisioning

func (s *retryProvisioningSuite) TestBlockRetryProvisioning(c *gc.C) {
	s.fake.err = common.ErrOperationBlocked("TestBlockRetryProvisioning")
	command := environment.NewRetryProvisioningCommand(s.fake)

	for i, t := range resolvedMachineTests {
		c.Logf("test %d: %v", i, t.args)
		_, err := testing.RunCommand(c, envcmd.Wrap(command), t.args...)
		if t.err != "" {
			c.Check(err, gc.ErrorMatches, t.err)
			continue
		}
		c.Assert(err, gc.ErrorMatches, cmd.ErrSilent.Error())
		// msg is logged
		stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
		c.Check(stripped, gc.Matches, ".*TestBlockRetryProvisioning.*")
	}
}
开发者ID:Pankov404,项目名称:juju,代码行数:17,代码来源:retryprovisioning_test.go


示例12: Run

func (m *mockRunAPI) Run(runParams params.RunParams) ([]params.RunResult, error) {
	var result []params.RunResult

	if m.block {
		return result, common.ErrOperationBlocked("The operation has been blocked.")
	}
	// Just add in ids that match in order.
	for _, id := range runParams.Machines {
		response, found := m.responses[id]
		if found {
			result = append(result, response)
		}
	}
	// mock ignores services
	for _, id := range runParams.Units {
		response, found := m.responses[id]
		if found {
			result = append(result, response)
		}
	}

	return result, nil
}
开发者ID:Pankov404,项目名称:juju,代码行数:23,代码来源:run_test.go


示例13: RunOnAllMachines

func (m *mockRunAPI) RunOnAllMachines(commands string, timeout time.Duration) ([]params.RunResult, error) {
	var result []params.RunResult

	if m.block {
		return result, common.ErrOperationBlocked("The operation has been blocked.")
	}
	sortedMachineIds := make([]string, 0, len(m.machines))
	for machineId := range m.machines {
		sortedMachineIds = append(sortedMachineIds, machineId)
	}
	sort.Strings(sortedMachineIds)

	for _, machineId := range sortedMachineIds {
		response, found := m.responses[machineId]
		if !found {
			// Consider this a timeout
			response = params.RunResult{MachineId: machineId, Error: "command timed out"}
		}
		result = append(result, response)
	}

	return result, nil
}
开发者ID:Pankov404,项目名称:juju,代码行数:23,代码来源:run_test.go


示例14: TestProcessErrOperationBlocked

func (s *BlockCommandSuite) TestProcessErrOperationBlocked(c *gc.C) {
	s.processErrorTest(c, common.ErrOperationBlocked("operations that remove"), block.BlockRemove, cmd.ErrSilent, ".*operations that remove.*")
	s.processErrorTest(c, common.ErrOperationBlocked("destroy-environment operation has been blocked"), block.BlockDestroy, cmd.ErrSilent, ".*destroy-environment operation has been blocked.*")
}
开发者ID:Pankov404,项目名称:juju,代码行数:4,代码来源:block_test.go


示例15:

	code:       params.CodeHasAssignedUnits,
	helperFunc: params.IsCodeHasAssignedUnits,
}, {
	err:        common.ErrTryAgain,
	code:       params.CodeTryAgain,
	helperFunc: params.IsCodeTryAgain,
}, {
	err:        state.UpgradeInProgressError,
	code:       params.CodeUpgradeInProgress,
	helperFunc: params.IsCodeUpgradeInProgress,
}, {
	err:        leadership.ErrClaimDenied,
	code:       params.CodeLeadershipClaimDenied,
	helperFunc: params.IsCodeLeadershipClaimDenied,
}, {
	err:        common.ErrOperationBlocked("test"),
	code:       params.CodeOperationBlocked,
	helperFunc: params.IsCodeOperationBlocked,
}, {
	err:        errors.NotSupportedf("needed feature"),
	code:       params.CodeNotSupported,
	helperFunc: params.IsCodeNotSupported,
}, {
	err:  stderrors.New("an error"),
	code: "",
}, {
	err:  unhashableError{"foo"},
	code: "",
}, {
	err:        common.UnknownEnvironmentError("dead-beef-123456"),
	code:       params.CodeNotFound,
开发者ID:ktsakalozos,项目名称:juju,代码行数:31,代码来源:errors_test.go


示例16: TestBlockSetEnviron

func (s *ConstraintsCommandsSuite) TestBlockSetEnviron(c *gc.C) {
	// Block operation
	s.fake.err = common.ErrOperationBlocked("TestBlockSetEnviron")
	// Set constraints.
	s.assertSetBlocked(c, "mem=4G", "cpu-power=250")
}
开发者ID:Pankov404,项目名称:juju,代码行数:6,代码来源:constraints_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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