本文整理汇总了Golang中github.com/juju/juju/provider/gce/google.NewZone函数的典型用法代码示例。如果您正苦于以下问题:Golang NewZone函数的具体用法?Golang NewZone怎么用?Golang NewZone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewZone函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestAvailabilityZones
func (s *environAZSuite) TestAvailabilityZones(c *gc.C) {
s.FakeConn.Zones = []google.AvailabilityZone{
google.NewZone("a-zone", google.StatusUp, "", ""),
google.NewZone("b-zone", google.StatusUp, "", ""),
}
zones, err := s.Env.AvailabilityZones()
c.Assert(err, jc.ErrorIsNil)
c.Check(zones, gc.HasLen, 2)
c.Check(zones[0].Name(), gc.Equals, "a-zone")
c.Check(zones[0].Available(), jc.IsTrue)
c.Check(zones[1].Name(), gc.Equals, "b-zone")
c.Check(zones[1].Available(), jc.IsTrue)
}
示例2: TestParsePlacement
func (s *environInstSuite) TestParsePlacement(c *gc.C) {
zone := google.NewZone("a-zone", google.StatusUp, "", "")
s.FakeConn.Zones = []google.AvailabilityZone{zone}
placement, err := gce.ParsePlacement(s.Env, "zone=a-zone")
c.Assert(err, jc.ErrorIsNil)
c.Check(placement.Zone, jc.DeepEquals, &zone)
}
示例3: TestParseAvailabilityZonesPlacementUnavailable
func (s *environAZSuite) TestParseAvailabilityZonesPlacementUnavailable(c *gc.C) {
s.StartInstArgs.Placement = "zone=a-zone"
s.FakeConn.Zones = []google.AvailabilityZone{
google.NewZone("a-zone", google.StatusDown, "", ""),
}
_, err := gce.ParseAvailabilityZones(s.Env, s.StartInstArgs)
c.Check(err, gc.ErrorMatches, `.*availability zone "a-zone" is DOWN`)
}
示例4: TestParseAvailabilityZonesPlacement
func (s *environAZSuite) TestParseAvailabilityZonesPlacement(c *gc.C) {
s.StartInstArgs.Placement = "zone=a-zone"
s.FakeConn.Zones = []google.AvailabilityZone{
google.NewZone("a-zone", google.StatusUp, "", ""),
}
zones, err := gce.ParseAvailabilityZones(s.Env, s.StartInstArgs)
c.Assert(err, jc.ErrorIsNil)
c.Check(zones, jc.DeepEquals, []string{"a-zone"})
}
示例5: TestPrecheckInstanceAvailZone
func (s *environPolSuite) TestPrecheckInstanceAvailZone(c *gc.C) {
s.FakeConn.Zones = []google.AvailabilityZone{
google.NewZone("a-zone", google.StatusUp, "", ""),
}
cons := constraints.Value{}
placement := "zone=a-zone"
err := s.Env.PrecheckInstance(testing.FakeDefaultSeries, cons, placement)
c.Check(err, jc.ErrorIsNil)
}
示例6: TestPrecheckInstanceAvailZoneUnknown
func (s *environPolSuite) TestPrecheckInstanceAvailZoneUnknown(c *gc.C) {
s.FakeConn.Zones = []google.AvailabilityZone{
google.NewZone("home-zone", google.StatusUp, "", ""),
}
cons := constraints.Value{}
placement := "zone=a-zone"
err := s.Env.PrecheckInstance(series.LatestLts(), cons, placement)
c.Check(err, jc.Satisfies, errors.IsNotFound)
}
示例7: TestPrecheckInstanceAvailZoneUnavailable
func (s *environPolSuite) TestPrecheckInstanceAvailZoneUnavailable(c *gc.C) {
s.FakeConn.Zones = []google.AvailabilityZone{
google.NewZone("a-zone", google.StatusDown, "", ""),
}
cons := constraints.Value{}
placement := "zone=a-zone"
err := s.Env.PrecheckInstance(series.LatestLts(), cons, placement)
c.Check(err, gc.ErrorMatches, `.*availability zone "a-zone" is DOWN`)
}
示例8: TestPrecheckInstanceAPI
func (s *environPolSuite) TestPrecheckInstanceAPI(c *gc.C) {
s.FakeConn.Zones = []google.AvailabilityZone{
google.NewZone("a-zone", google.StatusUp, "", ""),
}
cons := constraints.Value{}
placement := ""
err := s.Env.PrecheckInstance(series.LatestLts(), cons, placement)
c.Assert(err, jc.ErrorIsNil)
c.Check(s.FakeConn.Calls, gc.HasLen, 0)
}
示例9: TestPrecheckInstanceFullAPI
func (s *environPolSuite) TestPrecheckInstanceFullAPI(c *gc.C) {
s.FakeConn.Zones = []google.AvailabilityZone{
google.NewZone("home-zone", google.StatusUp, "", ""),
}
cons := constraints.MustParse("instance-type=n1-standard-1 arch=amd64 root-disk=1G")
placement := "zone=home-zone"
err := s.Env.PrecheckInstance(testing.FakeDefaultSeries, cons, placement)
c.Assert(err, jc.ErrorIsNil)
c.Check(s.FakeConn.Calls, gc.HasLen, 1)
c.Check(s.FakeConn.Calls[0].FuncName, gc.Equals, "AvailabilityZones")
c.Check(s.FakeConn.Calls[0].Region, gc.Equals, "home")
}
示例10: TestParseAvailabilityZonesPlacementAPI
func (s *environAZSuite) TestParseAvailabilityZonesPlacementAPI(c *gc.C) {
s.StartInstArgs.Placement = "zone=a-zone"
s.FakeConn.Zones = []google.AvailabilityZone{
google.NewZone("a-zone", google.StatusUp, "", ""),
}
_, err := gce.ParseAvailabilityZones(s.Env, s.StartInstArgs)
c.Assert(err, jc.ErrorIsNil)
s.FakeEnviron.CheckCalls(c, []gce.FakeCall{})
s.FakeCommon.CheckCalls(c, []gce.FakeCall{})
c.Check(s.FakeConn.Calls, gc.HasLen, 1)
c.Check(s.FakeConn.Calls[0].FuncName, gc.Equals, "AvailabilityZones")
c.Check(s.FakeConn.Calls[0].Region, gc.Equals, "home")
}
示例11: TestListVolumesIgnoresNamesFormatteDifferently
func (s *volumeSourceSuite) TestListVolumesIgnoresNamesFormatteDifferently(c *gc.C) {
otherDisk := &google.Disk{
Id: 1234568,
Name: "juju-566fe7b2-c026-4a86-a2cc-84cb7f9a4868",
Zone: "home-zone",
Status: google.StatusReady,
Size: 1024,
Description: "",
}
s.FakeConn.GoogleDisks = []*google.Disk{s.BaseDisk, otherDisk}
s.FakeConn.Zones = []google.AvailabilityZone{google.NewZone("home-zone", "Ready", "", "")}
vols, err := s.source.ListVolumes()
c.Check(err, jc.ErrorIsNil)
c.Assert(vols, gc.HasLen, 1)
}
示例12: TestListVolumes
func (s *volumeSourceSuite) TestListVolumes(c *gc.C) {
s.FakeConn.GoogleDisks = []*google.Disk{s.BaseDisk}
s.FakeConn.Zones = []google.AvailabilityZone{google.NewZone("home-zone", "Ready", "", "")}
vols, err := s.source.ListVolumes()
c.Check(err, jc.ErrorIsNil)
c.Assert(vols, gc.HasLen, 1)
azsCalled, call := s.FakeConn.WasCalled("AvailabilityZones")
c.Check(call, gc.HasLen, 1)
c.Assert(azsCalled, jc.IsTrue)
c.Assert(call[0].Region, gc.Equals, "")
disksCalled, call := s.FakeConn.WasCalled("Disks")
c.Check(call, gc.HasLen, 1)
c.Assert(disksCalled, jc.IsTrue)
c.Assert(call[0].ZoneName, gc.Equals, "home-zone")
}
示例13: TestAvailabilityZonesDeprecated
func (s *environAZSuite) TestAvailabilityZonesDeprecated(c *gc.C) {
zone := google.NewZone("a-zone", google.StatusUp, "DEPRECATED", "b-zone")
c.Check(zone.Deprecated(), jc.IsTrue)
}