本文整理匯總了Golang中github.com/juju/juju/juju.DeployService函數的典型用法代碼示例。如果您正苦於以下問題:Golang DeployService函數的具體用法?Golang DeployService怎麽用?Golang DeployService使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DeployService函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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"))
}
示例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",
})
}
示例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)
}
示例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)
}
示例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"))
}
示例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")
}
示例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")
}
示例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")
}
示例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)
}
示例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)
}
示例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")
}
示例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")
}
示例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),
})
}
示例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)
}
示例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"})
}