本文整理匯總了Golang中github.com/juju/juju/provider/vsphere.ExposeEnvFakeClient函數的典型用法代碼示例。如果您正苦於以下問題:Golang ExposeEnvFakeClient函數的具體用法?Golang ExposeEnvFakeClient怎麽用?Golang ExposeEnvFakeClient使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ExposeEnvFakeClient函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestStartInstanceTriesToCreateInstanceInAllAvailabilityZones
func (s *environBrokerSuite) TestStartInstanceTriesToCreateInstanceInAllAvailabilityZones(c *gc.C) {
client := vsphere.ExposeEnvFakeClient(s.Env)
client.SetPropertyProxyHandler("FakeDatacenter", vsphere.RetrieveDatacenterProperties)
s.FakeInstances(client)
s.FakeAvailabilityZones(client, "z1", "z2")
s.FakeAvailabilityZones(client, "z1", "z2")
s.FakeAvailabilityZones(client, "z1", "z2")
client.SetPropertyProxyHandler("FakeDatacenter", vsphere.RetrieveDatacenterProperties)
client.SetProxyHandler("CreateImportSpec", func(req, res soap.HasFault) {
resBody := res.(*methods.CreateImportSpecBody)
resBody.Res = &types.CreateImportSpecResponse{
Returnval: types.OvfCreateImportSpecResult{
Error: []types.LocalizedMethodFault{{
LocalizedMessage: "Error zone 1",
}},
},
}
})
s.FakeAvailabilityZones(client, "z1", "z2")
client.SetPropertyProxyHandler("FakeDatacenter", vsphere.RetrieveDatacenterProperties)
client.SetProxyHandler("CreateImportSpec", func(req, res soap.HasFault) {
resBody := res.(*methods.CreateImportSpecBody)
resBody.Res = &types.CreateImportSpecResponse{
Returnval: types.OvfCreateImportSpecResult{
Error: []types.LocalizedMethodFault{{
LocalizedMessage: "Error zone 2",
}},
},
}
})
startInstArgs := s.CreateStartInstanceArgs(c)
_, err := s.Env.StartInstance(startInstArgs)
c.Assert(err, gc.ErrorMatches, "Can't create instance in any of availability zones, last error: Failed to import OVA file: Error zone 2")
}
示例2: TestInstancesReturnNoInstances
func (s *environAvailzonesSuite) TestInstancesReturnNoInstances(c *gc.C) {
client := vsphere.ExposeEnvFakeClient(s.Env)
client.SetPropertyProxyHandler("FakeDatacenter", vsphere.RetrieveDatacenterProperties)
s.FakeInstancesWithResourcePool(client, vsphere.InstRp{Inst: "Some name that don't match naming convention", Rp: "rp1"})
_, err := s.Env.Instances([]instance.Id{instance.Id("Some other name")})
c.Assert(err, gc.Equals, environs.ErrNoInstances)
}
示例3: TestAvailabilityZones
func (s *environAvailzonesSuite) TestAvailabilityZones(c *gc.C) {
client := vsphere.ExposeEnvFakeClient(s.Env)
s.FakeAvailabilityZones(client, "z1", "z2")
zones, err := s.Env.AvailabilityZones()
c.Assert(err, jc.ErrorIsNil)
c.Assert(len(zones), gc.Equals, 2)
c.Assert(zones[0].Name(), gc.Equals, "z1")
c.Assert(zones[1].Name(), gc.Equals, "z2")
}
示例4: TestStartInstanceSelectZone
func (s *environBrokerSuite) TestStartInstanceSelectZone(c *gc.C) {
client := vsphere.ExposeEnvFakeClient(s.Env)
s.FakeAvailabilityZones(client, "z1", "z2")
s.FakeAvailabilityZones(client, "z1", "z2")
s.FakeCreateInstance(client, s.ServerUrl, c)
startInstArgs := s.CreateStartInstanceArgs(c)
startInstArgs.Placement = "zone=z2"
_, err := s.Env.StartInstance(startInstArgs)
c.Assert(err, jc.ErrorIsNil)
}
示例5: PrepareStartInstanceFakes
func (s *environBrokerSuite) PrepareStartInstanceFakes(c *gc.C) {
imagetesting.PatchOfficialDataSources(&s.CleanupSuite, "")
client := vsphere.ExposeEnvFakeClient(s.Env)
client.SetPropertyProxyHandler("FakeDatacenter", vsphere.RetrieveDatacenterProperties)
s.FakeInstances(client)
s.FakeAvailabilityZones(client, "z1")
s.FakeAvailabilityZones(client, "z1")
s.FakeAvailabilityZones(client, "z1")
s.FakeCreateInstance(client, s.ServerUrl, c)
}
示例6: TestInstancesReturnPartialInstances
func (s *environAvailzonesSuite) TestInstancesReturnPartialInstances(c *gc.C) {
client := vsphere.ExposeEnvFakeClient(s.Env)
client.SetPropertyProxyHandler("FakeDatacenter", vsphere.RetrieveDatacenterProperties)
vmName1 := common.MachineFullName(s.Env, "1")
vmName2 := common.MachineFullName(s.Env, "2")
s.FakeInstancesWithResourcePool(client, vsphere.InstRp{Inst: vmName1, Rp: "rp1"}, vsphere.InstRp{Inst: "Some inst", Rp: "rp2"})
_, err := s.Env.Instances([]instance.Id{instance.Id(vmName1), instance.Id(vmName2)})
c.Assert(err, gc.Equals, environs.ErrPartialInstances)
}
示例7: PrepareStartInstanceFakes
func (s *environBrokerSuite) PrepareStartInstanceFakes(c *gc.C) {
// Prevent falling over to the public datasource.
s.BaseSuite.PatchValue(&imagemetadata.DefaultBaseURL, "")
client := vsphere.ExposeEnvFakeClient(s.Env)
client.SetPropertyProxyHandler("FakeDatacenter", vsphere.RetrieveDatacenterProperties)
s.FakeInstances(client)
s.FakeAvailabilityZones(client, "z1")
s.FakeAvailabilityZones(client, "z1")
s.FakeAvailabilityZones(client, "z1")
s.FakeCreateInstance(client, s.ServerUrl, c)
}
示例8: TestInstanceAvailabilityZoneNames
func (s *environAvailzonesSuite) TestInstanceAvailabilityZoneNames(c *gc.C) {
client := vsphere.ExposeEnvFakeClient(s.Env)
client.SetPropertyProxyHandler("FakeDatacenter", vsphere.RetrieveDatacenterProperties)
vmName := common.MachineFullName(s.Env, "1")
s.FakeInstancesWithResourcePool(client, vsphere.InstRp{Inst: vmName, Rp: "rp1"})
s.FakeAvailabilityZonesWithResourcePool(client, vsphere.ZoneRp{Zone: "z1", Rp: "rp1"}, vsphere.ZoneRp{Zone: "z2", Rp: "rp2"})
zones, err := s.Env.InstanceAvailabilityZoneNames([]instance.Id{instance.Id(vmName)})
c.Assert(err, jc.ErrorIsNil)
c.Assert(len(zones), gc.Equals, 1)
c.Assert(zones[0], gc.Equals, "z1")
}
示例9: TestInstances
func (s *environAvailzonesSuite) TestInstances(c *gc.C) {
client := vsphere.ExposeEnvFakeClient(s.Env)
client.SetPropertyProxyHandler("FakeDatacenter", vsphere.RetrieveDatacenterProperties)
vmName1 := common.MachineFullName(s.Env, "1")
vmName2 := common.MachineFullName(s.Env, "2")
s.FakeInstancesWithResourcePool(client, vsphere.InstRp{Inst: vmName1, Rp: "rp1"}, vsphere.InstRp{Inst: vmName2, Rp: "rp2"})
instances, err := s.Env.Instances([]instance.Id{instance.Id(vmName1), instance.Id(vmName2)})
c.Assert(err, jc.ErrorIsNil)
c.Assert(len(instances), gc.Equals, 2)
c.Assert(string(instances[0].Id()), gc.Equals, vmName1)
c.Assert(string(instances[1].Id()), gc.Equals, vmName2)
}