當前位置: 首頁>>代碼示例>>Golang>>正文


Golang google.NewZone函數代碼示例

本文整理匯總了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)

}
開發者ID:imoapps,項目名稱:juju,代碼行數:16,代碼來源:environ_availzones_test.go

示例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)
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:9,代碼來源:environ_instance_test.go

示例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`)
}
開發者ID:imoapps,項目名稱:juju,代碼行數:10,代碼來源:environ_availzones_test.go

示例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"})
}
開發者ID:imoapps,項目名稱:juju,代碼行數:11,代碼來源:environ_availzones_test.go

示例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)
}
開發者ID:imoapps,項目名稱:juju,代碼行數:11,代碼來源:environ_policy_test.go

示例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)
}
開發者ID:xushiwei,項目名稱:juju,代碼行數:11,代碼來源:environ_policy_test.go

示例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`)
}
開發者ID:xushiwei,項目名稱:juju,代碼行數:11,代碼來源:environ_policy_test.go

示例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)
}
開發者ID:xushiwei,項目名稱:juju,代碼行數:12,代碼來源:environ_policy_test.go

示例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")
}
開發者ID:imoapps,項目名稱:juju,代碼行數:14,代碼來源:environ_policy_test.go

示例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")
}
開發者ID:imoapps,項目名稱:juju,代碼行數:15,代碼來源:environ_availzones_test.go

示例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)
}
開發者ID:imoapps,項目名稱:juju,代碼行數:15,代碼來源:disks_test.go

示例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")
}
開發者ID:imoapps,項目名稱:juju,代碼行數:17,代碼來源:disks_test.go

示例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)
}
開發者ID:imoapps,項目名稱:juju,代碼行數:5,代碼來源:environ_availzones_test.go


注:本文中的github.com/juju/juju/provider/gce/google.NewZone函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。