本文整理汇总了Golang中github.com/juju/juju/provider/ec2.InstanceEC2函数的典型用法代码示例。如果您正苦于以下问题:Golang InstanceEC2函数的具体用法?Golang InstanceEC2怎么用?Golang InstanceEC2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InstanceEC2函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testStartInstanceAvailZoneOneConstrained
func (t *localServerSuite) testStartInstanceAvailZoneOneConstrained(c *gc.C, runInstancesError *amzec2.Error) {
env := t.Prepare(c)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{})
c.Assert(err, jc.ErrorIsNil)
mock := mockAvailabilityZoneAllocations{
result: []common.AvailabilityZoneInstances{
{ZoneName: "az1"}, {ZoneName: "az2"},
},
}
t.PatchValue(ec2.AvailabilityZoneAllocations, mock.AvailabilityZoneAllocations)
// The first call to RunInstances fails with an error indicating the AZ
// is constrained. The second attempt succeeds, and so allocates to az2.
var azArgs []string
realRunInstances := *ec2.RunInstances
t.PatchValue(ec2.RunInstances, func(e *amzec2.EC2, ri *amzec2.RunInstances) (*amzec2.RunInstancesResp, error) {
azArgs = append(azArgs, ri.AvailZone)
if len(azArgs) == 1 {
return nil, runInstancesError
}
return realRunInstances(e, ri)
})
inst, hwc := testing.AssertStartInstance(c, env, "1")
c.Assert(azArgs, gc.DeepEquals, []string{"az1", "az2"})
c.Assert(ec2.InstanceEC2(inst).AvailZone, gc.Equals, "az2")
c.Check(*hwc.AvailabilityZone, gc.Equals, "az2")
}
示例2: TestStartInstanceDistribution
func (t *localServerSuite) TestStartInstanceDistribution(c *gc.C) {
env := t.Prepare(c)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{})
c.Assert(err, jc.ErrorIsNil)
// test-available is the only available AZ, so AvailabilityZoneAllocations
// is guaranteed to return that.
inst, _ := testing.AssertStartInstance(c, env, "1")
c.Assert(ec2.InstanceEC2(inst).AvailZone, gc.Equals, "test-available")
}
示例3: TestStartInstanceDistribution
func (t *localServerSuite) TestStartInstanceDistribution(c *gc.C) {
env := t.Prepare(c)
envtesting.UploadFakeTools(c, env.Storage())
err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{})
c.Assert(err, gc.IsNil)
// test-available is the only available AZ, so BestAvailabilityZoneAllocations
// is guaranteed to return that.
inst, _ := testing.AssertStartInstance(c, env, "1")
c.Assert(ec2.InstanceEC2(inst).AvailZone, gc.Equals, "test-available")
}
示例4: TestStartInstanceConstraints
func (t *LiveTests) TestStartInstanceConstraints(c *gc.C) {
cons := constraints.MustParse("mem=2G")
inst, hc := testing.AssertStartInstanceWithConstraints(c, t.Env, "30", cons)
defer t.Env.StopInstances(inst.Id())
ec2inst := ec2.InstanceEC2(inst)
c.Assert(ec2inst.InstanceType, gc.Equals, "m1.medium")
c.Assert(*hc.Arch, gc.Equals, "amd64")
c.Assert(*hc.Mem, gc.Equals, uint64(3840))
c.Assert(*hc.RootDisk, gc.Equals, uint64(8192))
c.Assert(*hc.CpuCores, gc.Equals, uint64(1))
c.Assert(*hc.CpuPower, gc.Equals, uint64(200))
}
示例5: TestStartInstanceConstraints
func (t *LiveTests) TestStartInstanceConstraints(c *gc.C) {
t.PrepareOnce(c)
cons := constraints.MustParse("mem=4G")
inst, hc := testing.AssertStartInstanceWithConstraints(c, t.Env, t.ControllerUUID, "30", cons)
defer t.Env.StopInstances(inst.Id())
ec2inst := ec2.InstanceEC2(inst)
c.Assert(ec2inst.InstanceType, gc.Equals, "m4.large")
c.Assert(*hc.Arch, gc.Equals, "amd64")
c.Assert(*hc.Mem, gc.Equals, uint64(8*1024))
c.Assert(*hc.RootDisk, gc.Equals, uint64(8*1024))
c.Assert(*hc.CpuCores, gc.Equals, uint64(2))
}
示例6: TestInstanceTags
func (t *localServerSuite) TestInstanceTags(c *gc.C) {
env := t.Prepare(c)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{})
c.Assert(err, jc.ErrorIsNil)
instances, err := env.AllInstances()
c.Assert(err, jc.ErrorIsNil)
c.Assert(instances, gc.HasLen, 1)
ec2Inst := ec2.InstanceEC2(instances[0])
c.Assert(ec2Inst.Tags, jc.SameContents, []amzec2.Tag{
{"Name", "juju-sample-machine-0"},
{"juju-env-uuid", coretesting.EnvironmentTag.Id()},
{"juju-is-state", "true"},
})
}
示例7: TestInstanceAttributes
func (t *LiveTests) TestInstanceAttributes(c *gc.C) {
inst, hc := testing.AssertStartInstance(c, t.Env, "30")
defer t.Env.StopInstances(inst.Id())
// Sanity check for hardware characteristics.
c.Assert(hc.Arch, gc.NotNil)
c.Assert(hc.Mem, gc.NotNil)
c.Assert(hc.RootDisk, gc.NotNil)
c.Assert(hc.CpuCores, gc.NotNil)
c.Assert(hc.CpuPower, gc.NotNil)
addresses, err := jujutesting.WaitInstanceAddresses(t.Env, inst.Id())
// TODO(niemeyer): This assert sometimes fails with "no instances found"
c.Assert(err, gc.IsNil)
c.Assert(addresses, gc.Not(gc.HasLen), 0)
insts, err := t.Env.Instances([]instance.Id{inst.Id()})
c.Assert(err, gc.IsNil)
c.Assert(len(insts), gc.Equals, 1)
ec2inst := ec2.InstanceEC2(insts[0])
c.Assert(ec2inst.DNSName, gc.Equals, addresses[0].Value)
c.Assert(ec2inst.InstanceType, gc.Equals, "m1.small")
}
示例8: TestStartInstanceAvailZone
func (t *localServerSuite) TestStartInstanceAvailZone(c *gc.C) {
inst, err := t.testStartInstanceAvailZone(c, "test-available")
c.Assert(err, jc.ErrorIsNil)
c.Assert(ec2.InstanceEC2(inst).AvailZone, gc.Equals, "test-available")
}