本文整理汇总了Golang中github.com/juju/juju/apiserver/modelmanager.NewModelManagerAPI函数的典型用法代码示例。如果您正苦于以下问题:Golang NewModelManagerAPI函数的具体用法?Golang NewModelManagerAPI怎么用?Golang NewModelManagerAPI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewModelManagerAPI函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestNewAPIAcceptsClient
func (s *modelManagerSuite) TestNewAPIAcceptsClient(c *gc.C) {
anAuthoriser := s.authoriser
anAuthoriser.Tag = names.NewUserTag("[email protected]")
endPoint, err := modelmanager.NewModelManagerAPI(s.State, s.resources, anAuthoriser)
c.Assert(err, jc.ErrorIsNil)
c.Assert(endPoint, gc.NotNil)
}
开发者ID:pmatulis,项目名称:juju,代码行数:7,代码来源:modelmanager_test.go
示例2: TestNewAPIRefusesNonClient
func (s *modelManagerSuite) TestNewAPIRefusesNonClient(c *gc.C) {
anAuthoriser := s.authoriser
anAuthoriser.Tag = names.NewUnitTag("mysql/0")
endPoint, err := modelmanager.NewModelManagerAPI(s.State, s.resources, anAuthoriser)
c.Assert(endPoint, gc.IsNil)
c.Assert(err, gc.ErrorMatches, "permission denied")
}
开发者ID:pmatulis,项目名称:juju,代码行数:7,代码来源:modelmanager_test.go
示例3: TestDestroyOwnModel
func (s *modelManagerStateSuite) TestDestroyOwnModel(c *gc.C) {
// TODO(perrito666) this test is not valid until we have
// proper controller permission since the only users that
// can create models are controller admins.
owner := names.NewUserTag("[email protected]")
s.setAPIUser(c, owner)
m, err := s.modelmanager.CreateModel(s.createArgs(c, owner))
c.Assert(err, jc.ErrorIsNil)
st, err := s.State.ForModel(names.NewModelTag(m.UUID))
c.Assert(err, jc.ErrorIsNil)
defer st.Close()
s.modelmanager, err = modelmanager.NewModelManagerAPI(
common.NewModelManagerBackend(st), nil, s.authoriser,
)
c.Assert(err, jc.ErrorIsNil)
results, err := s.modelmanager.DestroyModels(params.Entities{
Entities: []params.Entity{{"model-" + m.UUID}},
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(results.Results, gc.HasLen, 1)
c.Assert(results.Results[0].Error, gc.IsNil)
model, err := st.Model()
c.Assert(err, jc.ErrorIsNil)
c.Assert(model.Life(), gc.Not(gc.Equals), state.Alive)
}
开发者ID:kat-co,项目名称:juju,代码行数:28,代码来源:modelmanager_test.go
示例4: TestAdminDestroysOtherModel
func (s *modelManagerStateSuite) TestAdminDestroysOtherModel(c *gc.C) {
// TODO(perrito666) Both users are admins in this case, this tesst is of dubious
// usefulness until proper controller permissions are in place.
owner := names.NewUserTag("[email protected]")
s.setAPIUser(c, owner)
m, err := s.modelmanager.CreateModel(s.createArgs(c, owner))
c.Assert(err, jc.ErrorIsNil)
st, err := s.State.ForModel(names.NewModelTag(m.UUID))
c.Assert(err, jc.ErrorIsNil)
defer st.Close()
s.modelmanager, err = modelmanager.NewModelManagerAPI(
common.NewModelManagerBackend(st), nil, s.authoriser,
)
c.Assert(err, jc.ErrorIsNil)
other := s.AdminUserTag(c)
s.setAPIUser(c, other)
results, err := s.modelmanager.DestroyModels(params.Entities{
Entities: []params.Entity{{"model-" + m.UUID}},
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(results.Results, gc.HasLen, 1)
c.Assert(results.Results[0].Error, gc.IsNil)
s.setAPIUser(c, owner)
model, err := st.Model()
c.Assert(err, jc.ErrorIsNil)
c.Assert(model.Life(), gc.Not(gc.Equals), state.Alive)
}
开发者ID:kat-co,项目名称:juju,代码行数:31,代码来源:modelmanager_test.go
示例5: setAPIUser
func (s *modelManagerBaseSuite) setAPIUser(c *gc.C, user names.UserTag) {
s.authoriser.Tag = user
modelmanager, err := modelmanager.NewModelManagerAPI(
modelmanager.NewStateBackend(s.State), s.authoriser,
)
c.Assert(err, jc.ErrorIsNil)
s.modelmanager = modelmanager
}
开发者ID:makyo,项目名称:juju,代码行数:8,代码来源:modelmanager_test.go
示例6: TestNewAPIAcceptsClient
func (s *modelManagerStateSuite) TestNewAPIAcceptsClient(c *gc.C) {
anAuthoriser := s.authoriser
anAuthoriser.Tag = names.NewUserTag("[email protected]")
endPoint, err := modelmanager.NewModelManagerAPI(
common.NewModelManagerBackend(s.State), nil, anAuthoriser,
)
c.Assert(err, jc.ErrorIsNil)
c.Assert(endPoint, gc.NotNil)
}
开发者ID:kat-co,项目名称:juju,代码行数:9,代码来源:modelmanager_test.go
示例7: setAPIUser
func (s *modelManagerStateSuite) setAPIUser(c *gc.C, user names.UserTag) {
s.authoriser.Tag = user
modelmanager, err := modelmanager.NewModelManagerAPI(
common.NewModelManagerBackend(s.State),
stateenvirons.EnvironConfigGetter{s.State},
s.authoriser,
)
c.Assert(err, jc.ErrorIsNil)
s.modelmanager = modelmanager
}
开发者ID:kat-co,项目名称:juju,代码行数:10,代码来源:modelmanager_test.go
示例8: TestDestroyModelErrors
func (s *modelManagerStateSuite) TestDestroyModelErrors(c *gc.C) {
owner := names.NewUserTag("[email protected]")
s.setAPIUser(c, owner)
m, err := s.modelmanager.CreateModel(s.createArgs(c, owner))
c.Assert(err, jc.ErrorIsNil)
st, err := s.State.ForModel(names.NewModelTag(m.UUID))
c.Assert(err, jc.ErrorIsNil)
defer st.Close()
s.modelmanager, err = modelmanager.NewModelManagerAPI(
common.NewModelManagerBackend(st), nil, s.authoriser,
)
c.Assert(err, jc.ErrorIsNil)
user := names.NewUserTag("[email protected]")
s.setAPIUser(c, user)
results, err := s.modelmanager.DestroyModels(params.Entities{
Entities: []params.Entity{
{"model-" + m.UUID},
{"model-9f484882-2f18-4fd2-967d-db9663db7bea"},
{"machine-42"},
},
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(results.Results, jc.DeepEquals, []params.ErrorResult{{
// we don't have admin access to the model
¶ms.Error{
Message: "permission denied",
Code: params.CodeUnauthorized,
},
}, {
¶ms.Error{
Message: "model not found",
Code: params.CodeNotFound,
},
}, {
¶ms.Error{
Message: `"machine-42" is not a valid model tag`,
},
}})
s.setAPIUser(c, owner)
model, err := st.Model()
c.Assert(err, jc.ErrorIsNil)
c.Assert(model.Life(), gc.Equals, state.Alive)
}
开发者ID:kat-co,项目名称:juju,代码行数:47,代码来源:modelmanager_test.go
示例9: SetUpTest
func (s *modelInfoSuite) SetUpTest(c *gc.C) {
s.BaseSuite.SetUpTest(c)
s.authorizer = apiservertesting.FakeAuthorizer{
Tag: names.NewUserTag("[email protected]"),
}
s.st = &mockState{
modelUUID: coretesting.ModelTag.Id(),
controllerUUID: coretesting.ControllerTag.Id(),
cloud: cloud.Cloud{
Type: "dummy",
AuthTypes: []cloud.AuthType{cloud.EmptyAuthType},
},
cfgDefaults: config.ModelDefaultAttributes{
"attr": config.AttributeDefaultValues{
Default: "",
Controller: "val",
Regions: []config.RegionDefaultValue{{
Name: "dummy",
Value: "val++"}}},
"attr2": config.AttributeDefaultValues{
Controller: "val3",
Default: "val2",
Regions: []config.RegionDefaultValue{{
Name: "left",
Value: "spam"}}},
},
}
s.st.controllerModel = &mockModel{
owner: names.NewUserTag("[email protected]"),
life: state.Alive,
cfg: coretesting.ModelConfig(c),
status: status.StatusInfo{
Status: status.Available,
Since: &time.Time{},
},
users: []*mockModelUser{{
userName: "admin",
access: permission.AdminAccess,
}, {
userName: "otheruser",
access: permission.AdminAccess,
}},
}
s.st.model = &mockModel{
owner: names.NewUserTag("[email protected]"),
cfg: coretesting.ModelConfig(c),
life: state.Dying,
status: status.StatusInfo{
Status: status.Destroying,
Since: &time.Time{},
},
users: []*mockModelUser{{
userName: "admin",
access: permission.AdminAccess,
}, {
userName: "bob",
displayName: "Bob",
access: permission.ReadAccess,
}, {
userName: "charlotte",
displayName: "Charlotte",
access: permission.ReadAccess,
}, {
userName: "mary",
displayName: "Mary",
access: permission.WriteAccess,
}},
}
s.st.machines = []common.Machine{
&mockMachine{
id: "1",
containerType: "none",
life: state.Alive,
hw: &instance.HardwareCharacteristics{CpuCores: pUint64(1)},
},
&mockMachine{
id: "2",
life: state.Alive,
containerType: "lxc",
},
&mockMachine{
id: "3",
life: state.Dead,
},
}
var err error
s.modelmanager, err = modelmanager.NewModelManagerAPI(s.st, nil, &s.authorizer)
c.Assert(err, jc.ErrorIsNil)
}
开发者ID:bac,项目名称:juju,代码行数:92,代码来源:modelinfo_test.go
示例10: SetUpTest
func (s *modelManagerSuite) SetUpTest(c *gc.C) {
s.IsolationSuite.SetUpTest(c)
attrs := dummy.SampleConfig()
attrs["agent-version"] = jujuversion.Current.String()
cfg, err := config.New(config.UseDefaults, attrs)
c.Assert(err, jc.ErrorIsNil)
dummyCloud := cloud.Cloud{
Type: "dummy",
AuthTypes: []cloud.AuthType{cloud.EmptyAuthType},
Regions: []cloud.Region{
{Name: "some-region"},
{Name: "qux"},
},
}
s.st = &mockState{
modelUUID: coretesting.ModelTag.Id(),
cloud: dummyCloud,
clouds: map[names.CloudTag]cloud.Cloud{
names.NewCloudTag("some-cloud"): dummyCloud,
},
controllerModel: &mockModel{
owner: names.NewUserTag("[email protected]"),
life: state.Alive,
cfg: cfg,
status: status.StatusInfo{
Status: status.Available,
Since: &time.Time{},
},
users: []*mockModelUser{{
userName: "admin",
access: permission.AdminAccess,
}, {
userName: "otheruser",
access: permission.WriteAccess,
}},
},
model: &mockModel{
owner: names.NewUserTag("[email protected]"),
life: state.Alive,
tag: coretesting.ModelTag,
cfg: cfg,
status: status.StatusInfo{
Status: status.Available,
Since: &time.Time{},
},
users: []*mockModelUser{{
userName: "admin",
access: permission.AdminAccess,
}, {
userName: "otheruser",
access: permission.WriteAccess,
}},
},
cred: cloud.NewEmptyCredential(),
cfgDefaults: config.ModelDefaultAttributes{
"attr": config.AttributeDefaultValues{
Default: "",
Controller: "val",
Regions: []config.RegionDefaultValue{{
Name: "dummy",
Value: "val++"}}},
"attr2": config.AttributeDefaultValues{
Controller: "val3",
Default: "val2",
Regions: []config.RegionDefaultValue{{
Name: "left",
Value: "spam"}}},
},
}
s.authoriser = apiservertesting.FakeAuthorizer{
Tag: names.NewUserTag("[email protected]"),
}
api, err := modelmanager.NewModelManagerAPI(s.st, nil, s.authoriser)
c.Assert(err, jc.ErrorIsNil)
s.api = api
}
开发者ID:kat-co,项目名称:juju,代码行数:79,代码来源:modelmanager_test.go
注:本文中的github.com/juju/juju/apiserver/modelmanager.NewModelManagerAPI函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论