本文整理汇总了Golang中github.com/juju/juju/api/undertaker.NewClient函数的典型用法代码示例。如果您正苦于以下问题:Golang NewClient函数的具体用法?Golang NewClient怎么用?Golang NewClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewClient函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestSystemKillCallsEnvironDestroyOnHostedEnviron
func (s *cmdControllerSuite) TestSystemKillCallsEnvironDestroyOnHostedEnviron(c *gc.C) {
st := s.Factory.MakeEnvironment(c, &factory.EnvParams{
Name: "foo",
})
defer st.Close()
st.SwitchBlockOn(state.DestroyBlock, "TestBlockDestroyEnvironment")
st.Close()
opc := make(chan dummy.Operation, 200)
dummy.Listen(opc)
conn, err := juju.NewAPIState(s.AdminUserTag(c), s.Environ, api.DialOpts{})
c.Assert(err, jc.ErrorIsNil)
s.AddCleanup(func(*gc.C) { conn.Close() })
client := undertakerapi.NewClient(conn)
startTime := time.Date(2015, time.September, 1, 17, 2, 1, 0, time.UTC)
mClock := testing.NewClock(startTime)
undertaker.NewUndertaker(client, mClock)
store, err := configstore.Default()
_, err = store.ReadInfo("dummyenv")
c.Assert(err, jc.ErrorIsNil)
s.run(c, "kill-controller", "dummyenv", "-y")
// Ensure that Destroy was called on the hosted environment ...
opRecvTimeout(c, st, opc, dummy.OpDestroy{})
// ... and that the configstore was removed.
_, err = store.ReadInfo("dummyenv")
c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:imoapps,项目名称:juju,代码行数:34,代码来源:cmd_juju_controller_test.go
示例2: hostedAPI
func (s *undertakerSuite) hostedAPI(c *gc.C) (*undertaker.Client, *state.State) {
otherState := s.Factory.MakeModel(c, &factory.ModelParams{Name: "hosted_env"})
password, err := utils.RandomPassword()
c.Assert(err, jc.ErrorIsNil)
machine := s.Factory.MakeMachine(c, &factory.MachineParams{
Jobs: []state.MachineJob{state.JobManageModel},
Password: password,
Nonce: "fake_nonce",
})
// Connect to hosted environ from controller.
info := s.APIInfo(c)
info.Tag = machine.Tag()
info.Password = password
info.Nonce = "fake_nonce"
info.ModelTag = otherState.ModelTag()
otherAPIState, err := api.Open(info, api.DefaultDialOpts())
c.Assert(err, jc.ErrorIsNil)
undertakerClient := undertaker.NewClient(otherAPIState)
c.Assert(undertakerClient, gc.NotNil)
return undertakerClient, otherState
}
开发者ID:exekias,项目名称:juju,代码行数:27,代码来源:api_undertaker_test.go
示例3: TestWatchEnvironResourcesGetsChange
func (s *undertakerSuite) TestWatchEnvironResourcesGetsChange(c *gc.C) {
apiCaller := basetesting.APICallerFunc(
func(objType string,
version int,
id, request string,
args, response interface{},
) error {
if resp, ok := response.(*params.NotifyWatchResults); ok {
c.Check(objType, gc.Equals, "Undertaker")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "WatchEnvironResources")
a, ok := args.(params.Entities)
c.Check(ok, jc.IsTrue)
c.Check(a.Entities, gc.DeepEquals, []params.Entity{{Tag: "environment-"}})
resp.Results = []params.NotifyWatchResult{{NotifyWatcherId: "1"}}
} else {
c.Check(objType, gc.Equals, "NotifyWatcher")
c.Check(id, gc.Equals, "1")
c.Check(request, gc.Equals, "Next")
}
return nil
})
client := undertaker.NewClient(apiCaller)
w, err := client.WatchEnvironResources()
c.Assert(err, jc.ErrorIsNil)
select {
case <-w.Changes():
case <-time.After(coretesting.ShortWait):
c.Fatalf("timed out waiting for change")
}
}
开发者ID:imoapps,项目名称:juju,代码行数:35,代码来源:undertaker_test.go
示例4: TestStateRemoveEnvironFails
func (s *undertakerSuite) TestStateRemoveEnvironFails(c *gc.C) {
st, _ := s.OpenAPIAsNewMachine(c, state.JobManageModel)
undertakerClient, err := undertaker.NewClient(st, apiwatcher.NewNotifyWatcher)
c.Assert(err, jc.ErrorIsNil)
c.Assert(undertakerClient, gc.NotNil)
c.Assert(undertakerClient.RemoveModel(), gc.ErrorMatches, "an error occurred, unable to remove model")
}
开发者ID:kat-co,项目名称:juju,代码行数:7,代码来源:api_undertaker_test.go
示例5: NewFacade
// NewFacade creates a Facade from a base.APICaller, by calling the
// constructor in api/undertaker that returns a more specific type.
func NewFacade(apiCaller base.APICaller) (Facade, error) {
facade, err := undertaker.NewClient(apiCaller, watcher.NewNotifyWatcher)
if err != nil {
return nil, errors.Trace(err)
}
return facade, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:9,代码来源:shim.go
示例6: TestPermDenied
func (s *undertakerSuite) TestPermDenied(c *gc.C) {
nonManagerMachine, _ := s.OpenAPIAsNewMachine(c, state.JobHostUnits)
for _, conn := range []api.Connection{
nonManagerMachine,
s.APIState,
} {
undertakerClient := undertaker.NewClient(conn)
c.Assert(undertakerClient, gc.NotNil)
_, err := undertakerClient.ModelInfo()
c.Assert(err, gc.ErrorMatches, "permission denied")
}
}
开发者ID:exekias,项目名称:juju,代码行数:13,代码来源:api_undertaker_test.go
示例7: TestPermDenied
func (s *undertakerSuite) TestPermDenied(c *gc.C) {
nonManagerMachine, _ := s.OpenAPIAsNewMachine(c, state.JobHostUnits)
for _, conn := range []api.Connection{
nonManagerMachine,
s.APIState,
} {
undertakerClient := undertaker.NewClient(conn)
c.Assert(undertakerClient, gc.NotNil)
_, err := undertakerClient.ModelInfo()
c.Assert(errors.Cause(err), gc.DeepEquals, &rpc.RequestError{
Message: "permission denied",
Code: "unauthorized access",
})
}
}
开发者ID:OSBI,项目名称:juju,代码行数:16,代码来源:api_undertaker_test.go
示例8: TestStateProcessDyingEnviron
func (s *undertakerSuite) TestStateProcessDyingEnviron(c *gc.C) {
st, _ := s.OpenAPIAsNewMachine(c, state.JobManageModel)
undertakerClient := undertaker.NewClient(st)
c.Assert(undertakerClient, gc.NotNil)
err := undertakerClient.ProcessDyingModel()
c.Assert(err, gc.ErrorMatches, "model is not dying")
env, err := s.State.Model()
c.Assert(err, jc.ErrorIsNil)
c.Assert(env.Destroy(), jc.ErrorIsNil)
c.Assert(env.Refresh(), jc.ErrorIsNil)
c.Assert(env.Life(), gc.Equals, state.Dying)
err = undertakerClient.ProcessDyingModel()
c.Assert(err, gc.ErrorMatches, `model not empty, found 1 machine\(s\)`)
}
开发者ID:exekias,项目名称:juju,代码行数:17,代码来源:api_undertaker_test.go
示例9: TestStateEnvironInfo
func (s *undertakerSuite) TestStateEnvironInfo(c *gc.C) {
st, _ := s.OpenAPIAsNewMachine(c, state.JobManageModel)
undertakerClient := undertaker.NewClient(st)
c.Assert(undertakerClient, gc.NotNil)
result, err := undertakerClient.ModelInfo()
c.Assert(err, jc.ErrorIsNil)
c.Assert(result, gc.NotNil)
c.Assert(result.Error, gc.IsNil)
info := result.Result
c.Assert(info.UUID, gc.Equals, coretesting.ModelTag.Id())
c.Assert(info.Name, gc.Equals, "dummymodel")
c.Assert(info.GlobalName, gc.Equals, "[email protected]/dummymodel")
c.Assert(info.IsSystem, jc.IsTrue)
c.Assert(info.Life, gc.Equals, params.Alive)
c.Assert(info.TimeOfDeath, gc.IsNil)
}
开发者ID:exekias,项目名称:juju,代码行数:17,代码来源:api_undertaker_test.go
示例10: TestStateEnvironInfo
func (s *undertakerSuite) TestStateEnvironInfo(c *gc.C) {
st, _ := s.OpenAPIAsNewMachine(c, state.JobManageModel)
undertakerClient, err := undertaker.NewClient(st, apiwatcher.NewNotifyWatcher)
c.Assert(err, jc.ErrorIsNil)
c.Assert(undertakerClient, gc.NotNil)
result, err := undertakerClient.ModelInfo()
c.Assert(err, jc.ErrorIsNil)
c.Assert(result, gc.NotNil)
c.Assert(result.Error, gc.IsNil)
info := result.Result
c.Assert(info.UUID, gc.Equals, coretesting.ModelTag.Id())
c.Assert(info.Name, gc.Equals, "controller")
c.Assert(info.GlobalName, gc.Equals, "user-admin/controller")
c.Assert(info.IsSystem, jc.IsTrue)
c.Assert(info.Life, gc.Equals, params.Alive)
}
开发者ID:bac,项目名称:juju,代码行数:17,代码来源:api_undertaker_test.go
示例11: mockClient
func (s *undertakerSuite) mockClient(c *gc.C, expectedRequest string, callback func(response interface{})) *undertaker.Client {
apiCaller := basetesting.APICallerFunc(
func(objType string,
version int,
id, request string,
args, response interface{},
) error {
c.Check(objType, gc.Equals, "Undertaker")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, expectedRequest)
a, ok := args.(params.Entities)
c.Check(ok, jc.IsTrue)
c.Check(a.Entities, gc.DeepEquals, []params.Entity{{Tag: "environment-"}})
callback(response)
return nil
})
return undertaker.NewClient(apiCaller)
}
开发者ID:imoapps,项目名称:juju,代码行数:21,代码来源:undertaker_test.go
示例12: mockClient
func (s *UndertakerSuite) mockClient(c *gc.C, expectedRequest string, callback func(response interface{})) *undertaker.Client {
apiCaller := basetesting.APICallerFunc(func(
objType string,
version int,
id, request string,
args, response interface{},
) error {
c.Check(objType, gc.Equals, "Undertaker")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, expectedRequest)
a, ok := args.(params.Entities)
c.Check(ok, jc.IsTrue)
c.Check(a.Entities, gc.DeepEquals, []params.Entity{{Tag: coretesting.ModelTag.String()}})
callback(response)
return nil
})
client, err := undertaker.NewClient(apiCaller, nil)
c.Assert(err, jc.ErrorIsNil)
return client
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:22,代码来源:undertaker_test.go
示例13: TestWatchModelResourcesCreatesWatcher
func (s *UndertakerSuite) TestWatchModelResourcesCreatesWatcher(c *gc.C) {
apiCaller := basetesting.APICallerFunc(func(
objType string,
version int,
id, request string,
args, response interface{},
) error {
c.Check(objType, gc.Equals, "Undertaker")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "WatchModelResources")
a, ok := args.(params.Entities)
c.Check(ok, jc.IsTrue)
c.Check(a.Entities, gc.DeepEquals, []params.Entity{{Tag: coretesting.ModelTag.String()}})
resp, ok := response.(*params.NotifyWatchResults)
c.Assert(ok, jc.IsTrue)
resp.Results = []params.NotifyWatchResult{{
NotifyWatcherId: "1001",
}}
return nil
})
expectWatcher := &fakeWatcher{}
newWatcher := func(apiCaller base.APICaller, result params.NotifyWatchResult) watcher.NotifyWatcher {
c.Check(apiCaller, gc.NotNil) // uncomparable
c.Check(result, gc.Equals, params.NotifyWatchResult{
NotifyWatcherId: "1001",
})
return expectWatcher
}
client, err := undertaker.NewClient(apiCaller, newWatcher)
c.Assert(err, jc.ErrorIsNil)
w, err := client.WatchModelResources()
c.Assert(err, jc.ErrorIsNil)
c.Check(w, gc.Equals, expectWatcher)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:38,代码来源:undertaker_test.go
示例14: TestStateRemoveEnvironFails
func (s *undertakerSuite) TestStateRemoveEnvironFails(c *gc.C) {
st, _ := s.OpenAPIAsNewMachine(c, state.JobManageEnviron)
undertakerClient := undertaker.NewClient(st)
c.Assert(undertakerClient, gc.NotNil)
c.Assert(undertakerClient.RemoveEnviron(), gc.ErrorMatches, "an error occurred, unable to remove environment")
}
开发者ID:imoapps,项目名称:juju,代码行数:6,代码来源:api_undertaker_test.go
注:本文中的github.com/juju/juju/api/undertaker.NewClient函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论