本文整理汇总了Golang中github.com/juju/juju/juju.DeployService函数的典型用法代码示例。如果您正苦于以下问题:Golang DeployService函数的具体用法?Golang DeployService怎么用?Golang DeployService使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DeployService函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestDeployWithFewerPlacement
func (s *DeployLocalSuite) TestDeployWithFewerPlacement(c *gc.C) {
err := s.State.SetEnvironConstraints(constraints.MustParse("mem=2G"))
c.Assert(err, jc.ErrorIsNil)
serviceCons := constraints.MustParse("cpu-cores=2")
service, err := juju.DeployService(s.State,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
Constraints: serviceCons,
NumUnits: 3,
Placement: []*instance.Placement{
{Scope: s.State.EnvironUUID(), Directive: "valid"},
},
})
c.Assert(err, jc.ErrorIsNil)
s.assertConstraints(c, service, serviceCons)
units, err := service.AllUnits()
c.Assert(err, jc.ErrorIsNil)
c.Assert(units, gc.HasLen, 3)
// Check each of the newly added units.
s.assertAssignedUnit(c, units[0], "0", constraints.MustParse("mem=2G cpu-cores=2"))
s.assertAssignedUnit(c, units[1], "1", constraints.MustParse("mem=2G cpu-cores=2"))
s.assertAssignedUnit(c, units[2], "2", constraints.MustParse("mem=2G cpu-cores=2"))
}
开发者ID:kakamessi99,项目名称:juju,代码行数:25,代码来源:deploy_test.go
示例2: TestDeployWithSomeSpecifiedBindings
func (s *DeployLocalSuite) TestDeployWithSomeSpecifiedBindings(c *gc.C) {
wordpressCharm := s.addWordpressCharm(c)
_, err := s.State.AddSpace("db", "", nil, false)
c.Assert(err, jc.ErrorIsNil)
_, err = s.State.AddSpace("public", "", nil, false)
c.Assert(err, jc.ErrorIsNil)
service, err := juju.DeployService(s.State,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: wordpressCharm,
EndpointBindings: map[string]string{
"": "public",
"db": "db",
},
})
c.Assert(err, jc.ErrorIsNil)
s.assertBindings(c, service, map[string]string{
"url": "public",
"logging-dir": "public",
"monitoring-port": "public",
"db": "db",
"cache": "public",
})
}
开发者ID:OSBI,项目名称:juju,代码行数:26,代码来源:deploy_test.go
示例3: TestDeploy
func (s *DeployLocalSuite) TestDeploy(c *gc.C) {
f := &fakeDeployer{State: s.State}
serviceCons := constraints.MustParse("cpu-cores=2")
placement := []*instance.Placement{
{Scope: s.State.ModelUUID(), Directive: "valid"},
{Scope: "#", Directive: "0"},
{Scope: "lxc", Directive: "1"},
{Scope: "lxc", Directive: ""},
}
_, err := juju.DeployService(f,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
Constraints: serviceCons,
NumUnits: 4,
Placement: placement,
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(f.args.Name, gc.Equals, "bob")
c.Assert(f.args.Charm, gc.DeepEquals, s.charm)
c.Assert(f.args.Constraints, gc.DeepEquals, serviceCons)
c.Assert(f.args.NumUnits, gc.Equals, 4)
c.Assert(f.args.Placement, gc.DeepEquals, placement)
}
开发者ID:OSBI,项目名称:juju,代码行数:26,代码来源:deploy_test.go
示例4: TestDeployForceMachineIdWithContainer
func (s *DeployLocalSuite) TestDeployForceMachineIdWithContainer(c *gc.C) {
machine, err := s.State.AddMachine("quantal", state.JobHostUnits)
c.Assert(err, gc.IsNil)
c.Assert(machine.Id(), gc.Equals, "0")
envCons := constraints.MustParse("mem=2G")
err = s.State.SetEnvironConstraints(envCons)
c.Assert(err, gc.IsNil)
serviceCons := constraints.MustParse("cpu-cores=2")
service, err := juju.DeployService(s.State,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
Constraints: serviceCons,
NumUnits: 1,
ToMachineSpec: fmt.Sprintf("%s:0", instance.LXC),
})
c.Assert(err, gc.IsNil)
s.assertConstraints(c, service, serviceCons)
units, err := service.AllUnits()
c.Assert(err, gc.IsNil)
c.Assert(units, gc.HasLen, 1)
// The newly created container will use the constraints.
id, err := units[0].AssignedMachineId()
c.Assert(err, gc.IsNil)
machine, err = s.State.Machine(id)
c.Assert(err, gc.IsNil)
machineCons, err := machine.Constraints()
c.Assert(err, gc.IsNil)
unitCons, err := units[0].Constraints()
c.Assert(err, gc.IsNil)
c.Assert(machineCons, gc.DeepEquals, *unitCons)
}
开发者ID:jiasir,项目名称:juju,代码行数:33,代码来源:deploy_test.go
示例5: TestDeployWithPlacement
func (s *DeployLocalSuite) TestDeployWithPlacement(c *gc.C) {
machine, err := s.State.AddMachine("quantal", state.JobHostUnits)
c.Assert(err, jc.ErrorIsNil)
c.Assert(machine.Id(), gc.Equals, "0")
err = s.State.SetEnvironConstraints(constraints.MustParse("mem=2G"))
c.Assert(err, jc.ErrorIsNil)
serviceCons := constraints.MustParse("cpu-cores=2")
service, err := juju.DeployService(s.State,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
Constraints: serviceCons,
NumUnits: 3,
Placement: []*instance.Placement{
{Scope: s.State.EnvironUUID(), Directive: "valid"},
{Scope: "#", Directive: "0"},
{Scope: "lxc", Directive: "1"},
},
ToMachineSpec: "will be ignored",
})
c.Assert(err, jc.ErrorIsNil)
s.assertConstraints(c, service, serviceCons)
units, err := service.AllUnits()
c.Assert(err, jc.ErrorIsNil)
c.Assert(units, gc.HasLen, 3)
// Check each of the newly added units.
s.assertAssignedUnit(c, units[0], "1", constraints.MustParse("mem=2G cpu-cores=2"))
s.assertAssignedUnit(c, units[1], "0", constraints.Value{})
s.assertAssignedUnit(c, units[2], "1/lxc/0", constraints.MustParse("mem=2G cpu-cores=2"))
}
开发者ID:kakamessi99,项目名称:juju,代码行数:31,代码来源:deploy_test.go
示例6: TestDeployOwnerTag
func (s *DeployLocalSuite) TestDeployOwnerTag(c *gc.C) {
s.Factory.MakeUser(factory.UserParams{Username: "foobar"})
service, err := juju.DeployService(s.State,
juju.DeployServiceParams{
ServiceName: "bobwithowner",
Charm: s.charm,
ServiceOwner: "user-foobar",
})
c.Assert(err, gc.IsNil)
c.Assert(service.GetOwnerTag(), gc.Equals, "user-foobar")
}
开发者ID:jiasir,项目名称:juju,代码行数:11,代码来源:deploy_test.go
示例7: TestDeployMinimal
func (s *DeployLocalSuite) TestDeployMinimal(c *gc.C) {
service, err := juju.DeployService(s.State,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
})
c.Assert(err, gc.IsNil)
s.assertCharm(c, service, s.charm.URL())
s.assertSettings(c, service, charm.Settings{})
s.assertConstraints(c, service, constraints.Value{})
s.assertMachines(c, service, constraints.Value{})
c.Assert(service.GetOwnerTag(), gc.Equals, "user-admin")
}
开发者ID:jiasir,项目名称:juju,代码行数:13,代码来源:deploy_test.go
示例8: TestDeployWithForceMachineRejectsTooManyUnits
func (s *DeployLocalSuite) TestDeployWithForceMachineRejectsTooManyUnits(c *gc.C) {
machine, err := s.State.AddMachine("quantal", state.JobHostUnits)
c.Assert(err, gc.IsNil)
c.Assert(machine.Id(), gc.Equals, "0")
_, err = juju.DeployService(s.State,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
NumUnits: 2,
ToMachineSpec: "0",
})
c.Assert(err, gc.ErrorMatches, "cannot use --num-units with --to")
}
开发者ID:jiasir,项目名称:juju,代码行数:13,代码来源:deploy_test.go
示例9: TestDeployConstraints
func (s *DeployLocalSuite) TestDeployConstraints(c *gc.C) {
err := s.State.SetEnvironConstraints(constraints.MustParse("mem=2G"))
c.Assert(err, gc.IsNil)
serviceCons := constraints.MustParse("cpu-cores=2")
service, err := juju.DeployService(s.State,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
Constraints: serviceCons,
})
c.Assert(err, gc.IsNil)
s.assertConstraints(c, service, serviceCons)
}
开发者ID:jiasir,项目名称:juju,代码行数:13,代码来源:deploy_test.go
示例10: TestDeploySettingsError
func (s *DeployLocalSuite) TestDeploySettingsError(c *gc.C) {
_, err := juju.DeployService(s.State,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
ConfigSettings: charm.Settings{
"skill-level": 99.01,
},
})
c.Assert(err, gc.ErrorMatches, `option "skill-level" expected int, got 99.01`)
_, err = s.State.Service("bob")
c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:jiasir,项目名称:juju,代码行数:13,代码来源:deploy_test.go
示例11: TestDeployNumUnits
func (s *DeployLocalSuite) TestDeployNumUnits(c *gc.C) {
err := s.State.SetEnvironConstraints(constraints.MustParse("mem=2G"))
c.Assert(err, jc.ErrorIsNil)
serviceCons := constraints.MustParse("cpu-cores=2")
service, err := juju.DeployService(s.State,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
Constraints: serviceCons,
NumUnits: 2,
})
c.Assert(err, jc.ErrorIsNil)
s.assertConstraints(c, service, serviceCons)
s.assertMachines(c, service, constraints.MustParse("mem=2G cpu-cores=2"), "0", "1")
}
开发者ID:kakamessi99,项目名称:juju,代码行数:15,代码来源:deploy_test.go
示例12: TestDeploySeries
func (s *DeployLocalSuite) TestDeploySeries(c *gc.C) {
f := &fakeDeployer{State: s.State}
_, err := juju.DeployService(f,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
Series: "aseries",
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(f.args.Name, gc.Equals, "bob")
c.Assert(f.args.Charm, gc.DeepEquals, s.charm)
c.Assert(f.args.Series, gc.Equals, "aseries")
}
开发者ID:OSBI,项目名称:juju,代码行数:15,代码来源:deploy_test.go
示例13: TestDeploySettings
func (s *DeployLocalSuite) TestDeploySettings(c *gc.C) {
service, err := juju.DeployService(s.State,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
ConfigSettings: charm.Settings{
"title": "banana cupcakes",
"skill-level": 9901,
},
})
c.Assert(err, gc.IsNil)
s.assertSettings(c, service, charm.Settings{
"title": "banana cupcakes",
"skill-level": int64(9901),
})
}
开发者ID:jiasir,项目名称:juju,代码行数:16,代码来源:deploy_test.go
示例14: TestDeployNumUnits
func (s *DeployLocalSuite) TestDeployNumUnits(c *gc.C) {
f := &fakeDeployer{State: s.State}
serviceCons := constraints.MustParse("cpu-cores=2")
_, err := juju.DeployService(f,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
Constraints: serviceCons,
NumUnits: 2,
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(f.args.Name, gc.Equals, "bob")
c.Assert(f.args.Charm, gc.DeepEquals, s.charm)
c.Assert(f.args.Constraints, gc.DeepEquals, serviceCons)
c.Assert(f.args.NumUnits, gc.Equals, 2)
}
开发者ID:OSBI,项目名称:juju,代码行数:18,代码来源:deploy_test.go
示例15: TestDeployResources
func (s *DeployLocalSuite) TestDeployResources(c *gc.C) {
f := &fakeDeployer{State: s.State}
_, err := juju.DeployService(f,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
EndpointBindings: map[string]string{
"": "public",
"db": "db",
},
Resources: map[string]string{"foo": "bar"},
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(f.args.Name, gc.Equals, "bob")
c.Assert(f.args.Charm, gc.DeepEquals, s.charm)
c.Assert(f.args.Resources, gc.DeepEquals, map[string]string{"foo": "bar"})
}
开发者ID:OSBI,项目名称:juju,代码行数:19,代码来源:deploy_test.go
示例16: TestDeployForceMachineId
func (s *DeployLocalSuite) TestDeployForceMachineId(c *gc.C) {
machine, err := s.State.AddMachine("quantal", state.JobHostUnits)
c.Assert(err, gc.IsNil)
c.Assert(machine.Id(), gc.Equals, "0")
err = s.State.SetEnvironConstraints(constraints.MustParse("mem=2G"))
c.Assert(err, gc.IsNil)
serviceCons := constraints.MustParse("cpu-cores=2")
service, err := juju.DeployService(s.State,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
Constraints: serviceCons,
NumUnits: 1,
ToMachineSpec: "0",
})
c.Assert(err, gc.IsNil)
s.assertConstraints(c, service, serviceCons)
s.assertMachines(c, service, constraints.Value{}, "0")
}
开发者ID:jiasir,项目名称:juju,代码行数:19,代码来源:deploy_test.go
示例17: TestDeployWithImplicitBindings
func (s *DeployLocalSuite) TestDeployWithImplicitBindings(c *gc.C) {
wordpressCharm := s.addWordpressCharm(c)
service, err := juju.DeployService(s.State,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: wordpressCharm,
EndpointBindings: nil,
})
c.Assert(err, jc.ErrorIsNil)
s.assertBindings(c, service, map[string]string{
"url": "",
"logging-dir": "",
"monitoring-port": "",
"db": "",
"cache": "",
})
}
开发者ID:OSBI,项目名称:juju,代码行数:19,代码来源:deploy_test.go
示例18: TestDeployForceMachineIdWithContainer
func (s *DeployLocalSuite) TestDeployForceMachineIdWithContainer(c *gc.C) {
f := &fakeDeployer{State: s.State}
serviceCons := constraints.MustParse("cpu-cores=2")
_, err := juju.DeployService(f,
juju.DeployServiceParams{
ServiceName: "bob",
Charm: s.charm,
Constraints: serviceCons,
NumUnits: 1,
Placement: []*instance.Placement{instance.MustParsePlacement(fmt.Sprintf("%s:0", instance.LXC))},
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(f.args.Name, gc.Equals, "bob")
c.Assert(f.args.Charm, gc.DeepEquals, s.charm)
c.Assert(f.args.Constraints, gc.DeepEquals, serviceCons)
c.Assert(f.args.NumUnits, gc.Equals, 1)
c.Assert(f.args.Placement, gc.HasLen, 1)
c.Assert(*f.args.Placement[0], gc.Equals, instance.Placement{Scope: string(instance.LXC), Directive: "0"})
}
开发者ID:OSBI,项目名称:juju,代码行数:20,代码来源:deploy_test.go
示例19: deployService
// DeployService fetches the charm from the charm store and deploys it.
// The logic has been factored out into a common function which is called by
// both the legacy API on the client facade, as well as the new service facade.
func deployService(st *state.State, owner string, args params.ServiceDeploy) error {
curl, err := charm.ParseURL(args.CharmUrl)
if err != nil {
return errors.Trace(err)
}
if curl.Revision < 0 {
return errors.Errorf("charm url must include revision")
}
// Do a quick but not complete validation check before going any further.
for _, p := range args.Placement {
if p.Scope != instance.MachineScope {
continue
}
_, err = st.Machine(p.Directive)
if err != nil {
return errors.Annotatef(err, `cannot deploy "%v" to machine %v`, args.ServiceName, p.Directive)
}
}
// Try to find the charm URL in state first.
ch, err := st.Charm(curl)
if errors.IsNotFound(err) {
// Clients written to expect 1.16 compatibility require this next block.
if curl.Schema != "cs" {
return errors.Errorf(`charm url has unsupported schema %q`, curl.Schema)
}
if err = AddCharmWithAuthorization(st, params.AddCharmWithAuthorization{
URL: args.CharmUrl,
}); err == nil {
ch, err = st.Charm(curl)
}
}
if err != nil {
return errors.Trace(err)
}
var settings charm.Settings
if len(args.ConfigYAML) > 0 {
settings, err = ch.Config().ParseSettingsYAML([]byte(args.ConfigYAML), args.ServiceName)
} else if len(args.Config) > 0 {
// Parse config in a compatible way (see function comment).
settings, err = parseSettingsCompatible(ch, args.Config)
}
if err != nil {
return errors.Trace(err)
}
// Convert network tags to names for any given networks.
requestedNetworks, err := networkTagsToNames(args.Networks)
if err != nil {
return errors.Trace(err)
}
_, err = jjj.DeployService(st,
jjj.DeployServiceParams{
ServiceName: args.ServiceName,
Series: args.Series,
// TODO(dfc) ServiceOwner should be a tag
ServiceOwner: owner,
Charm: ch,
NumUnits: args.NumUnits,
ConfigSettings: settings,
Constraints: args.Constraints,
Placement: args.Placement,
Networks: requestedNetworks,
Storage: args.Storage,
})
return errors.Trace(err)
}
开发者ID:exekias,项目名称:juju,代码行数:72,代码来源:service.go
注:本文中的github.com/juju/juju/juju.DeployService函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论