本文整理汇总了Golang中github.com/juju/juju/apiserver/common.OperationBlockedError函数的典型用法代码示例。如果您正苦于以下问题:Golang OperationBlockedError函数的具体用法?Golang OperationBlockedError怎么用?Golang OperationBlockedError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OperationBlockedError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestAddRelationBlocked
func (s *AddRelationSuite) TestAddRelationBlocked(c *gc.C) {
s.mockAPI.SetErrors(common.OperationBlockedError("TestBlockAddRelation"))
err := s.runAddRelation(c, "application1", "application2")
coretesting.AssertOperationWasBlocked(c, err, ".*TestBlockAddRelation.*")
s.mockAPI.CheckCall(c, 0, "AddRelation", []string{"application1", "application2"})
s.mockAPI.CheckCall(c, 1, "Close")
}
示例2: RunOnAllMachines
func (m *mockRunAPI) RunOnAllMachines(commands string, timeout time.Duration) ([]params.ActionResult, error) {
var result []params.ActionResult
if m.block {
return result, common.OperationBlockedError("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.runResponses[machineId]
if !found {
// Consider this a timeout
response = params.ActionResult{
Action: ¶ms.Action{
Receiver: names.NewMachineTag(machineId).String(),
},
Message: exec.ErrCancelled.Error(),
}
}
result = append(result, response)
}
return result, nil
}
示例3: TestBlockedError
func (s *SetSuite) TestBlockedError(c *gc.C) {
s.fake.err = common.OperationBlockedError("TestBlockedError")
_, err := s.run(c, "special=extra")
c.Assert(err, gc.Equals, cmd.ErrSilent)
// msg is logged
c.Check(c.GetTestLog(), jc.Contains, "TestBlockedError")
}
示例4: TestResetBlockedError
func (s *DefaultsCommandSuite) TestResetBlockedError(c *gc.C) {
s.fake.err = common.OperationBlockedError("TestBlockedError")
_, err := s.run(c, "--reset", "attr")
c.Assert(err, gc.Equals, cmd.ErrSilent)
// msg is logged
c.Check(c.GetTestLog(), jc.Contains, "TestBlockedError")
}
示例5: TestBlockedError
func (s *AddMachineSuite) TestBlockedError(c *gc.C) {
s.fakeAddMachine.addError = common.OperationBlockedError("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.*")
}
示例6: TestAPIAdapterBlockUploadTools
func (s *syncToolsSuite) TestAPIAdapterBlockUploadTools(c *gc.C) {
syncTools = func(sctx *sync.SyncContext) error {
// Block operation
return common.OperationBlockedError("TestAPIAdapterBlockUploadTools")
}
_, err := s.runSyncToolsCommand(c, "-m", "test-target", "--destination", c.MkDir(), "--stream", "released")
coretesting.AssertOperationWasBlocked(c, err, ".*TestAPIAdapterBlockUploadTools.*")
}
示例7: TestBlockSetService
func (s *ConstraintsCommandsSuite) TestBlockSetService(c *gc.C) {
s.fake.addTestingService("svc")
// Block operation
s.fake.err = common.OperationBlockedError("TestBlockSetService")
// Set constraints.
s.assertSetBlocked(c, "-s", "svc", "mem=4G", "cpu-power=250")
}
示例8: TestBlockAddUnit
func (s *AddUnitSuite) TestBlockAddUnit(c *gc.C) {
// Block operation
s.fake.err = common.OperationBlockedError("TestBlockAddUnit")
s.runAddUnit(c, "some-application-name")
// msg is logged
stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
c.Check(stripped, gc.Matches, ".*TestBlockAddUnit.*")
}
示例9: TestBlockedError
func (s *RemoveMachineSuite) TestBlockedError(c *gc.C) {
s.fake.removeError = common.OperationBlockedError("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.*")
}
示例10: TestBlockEnableHA
func (s *EnableHASuite) TestBlockEnableHA(c *gc.C) {
s.fake.err = common.OperationBlockedError("TestBlockEnableHA")
_, err := s.runEnableHA(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, ".*TestBlockEnableHA.*")
}
示例11: TestAPIAdapterBlockUploadTools
func (s *syncToolsSuite) TestAPIAdapterBlockUploadTools(c *gc.C) {
syncTools = func(sctx *sync.SyncContext) error {
// Block operation
return common.OperationBlockedError("TestAPIAdapterBlockUploadTools")
}
_, err := runSyncToolsCommand(c, "-m", "test-target", "--destination", c.MkDir(), "--stream", "released")
c.Assert(err, gc.ErrorMatches, cmd.ErrSilent.Error())
// msg is logged
stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
c.Check(stripped, gc.Matches, ".*TestAPIAdapterBlockUploadTools.*")
}
示例12: AddUser
func (m *mockAddUserAPI) AddUser(username, displayname, password string) (names.UserTag, []byte, error) {
if m.blocked {
return names.UserTag{}, nil, common.OperationBlockedError("the operation has been blocked")
}
m.username = username
m.displayname = displayname
m.password = password
if m.failMessage != "" {
return names.UserTag{}, nil, errors.New(m.failMessage)
}
return names.NewLocalUserTag(username), m.secretKey, nil
}
示例13: 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.OperationBlockedError("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))
}
示例14: TestBlockSetConfig
func (s *SetSuite) TestBlockSetConfig(c *gc.C) {
// Block operation
s.fakeServiceAPI.err = common.OperationBlockedError("TestBlockSetConfig")
ctx := coretesting.ContextForDir(c, s.dir)
code := cmd.Main(service.NewSetCommandWithAPI(s.fakeClientAPI, s.fakeServiceAPI), ctx, []string{
"dummy-service",
"--config",
"testconfig.yaml"})
c.Check(code, gc.Equals, 1)
// msg is logged
stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
c.Check(stripped, gc.Matches, ".*TestBlockSetConfig.*")
}
示例15: ensureNotBlocked
func (s *ControllerAPI) ensureNotBlocked(args params.DestroyControllerArgs) error {
// If there are blocks let the user know.
blocks, err := s.state.AllBlocksForController()
if err != nil {
logger.Debugf("Unable to get blocks for controller: %s", err)
return errors.Trace(err)
}
if len(blocks) > 0 {
return common.OperationBlockedError("found blocks in controller models")
}
return nil
}