本文整理匯總了Golang中github.com/maximilien/softlayer-go/softlayer.SoftLayer_Virtual_Guest_Service.GetObject方法的典型用法代碼示例。如果您正苦於以下問題:Golang SoftLayer_Virtual_Guest_Service.GetObject方法的具體用法?Golang SoftLayer_Virtual_Guest_Service.GetObject怎麽用?Golang SoftLayer_Virtual_Guest_Service.GetObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/maximilien/softlayer-go/softlayer.SoftLayer_Virtual_Guest_Service
的用法示例。
在下文中一共展示了SoftLayer_Virtual_Guest_Service.GetObject方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
log.Println("outputBytes=" + string(outputBytes))
Expect(err).ToNot(HaveOccurred())
err = json.Unmarshal(outputBytes, &resultOutput)
Expect(err).ToNot(HaveOccurred())
Expect(resultOutput["error"]).To(BeNil())
id := resultOutput["result"].(string)
vmId, err = strconv.Atoi(id)
Expect(err).ToNot(HaveOccurred())
Expect(vmId).ToNot(BeNil())
log.Println("---> created vm ", vmId)
testhelpers.WaitForVirtualGuestToBeRunning(vmId)
testhelpers.WaitForVirtualGuestToHaveNoActiveTransactions(vmId)
vm, err := virtualGuestService.GetObject(vmId)
Expect(err).ToNot(HaveOccurred())
disk = testhelpers.CreateDisk(20, strconv.Itoa(vm.Datacenter.Id))
strVGID = strconv.Itoa(vmId)
strDID = strconv.Itoa(disk.Id)
replacementMap = map[string]string{
"VMID": strVGID,
"DiskID": strDID,
}
})
AfterEach(func() {
testhelpers.DeleteVirtualGuest(vmId)
示例2:
Expect(err.Error()).To(ContainSubstring("Domain"))
Expect(err.Error()).To(ContainSubstring("StartCpus"))
Expect(err.Error()).To(ContainSubstring("MaxMemory"))
Expect(err.Error()).To(ContainSubstring("Datacenter"))
})
})
Context("#GetObject", func() {
BeforeEach(func() {
virtualGuest.Id = 1234567
fakeClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Virtual_Guest_Service_getObject.json")
Expect(err).ToNot(HaveOccurred())
})
It("sucessfully retrieves SoftLayer_Virtual_Guest instance", func() {
vg, err := virtualGuestService.GetObject(virtualGuest.Id)
Expect(err).ToNot(HaveOccurred())
Expect(vg.Id).To(Equal(virtualGuest.Id))
Expect(vg.AccountId).To(Equal(278444))
Expect(vg.CreateDate).ToNot(BeNil())
Expect(vg.DedicatedAccountHostOnlyFlag).To(BeFalse())
Expect(vg.Domain).To(Equal("softlayer.com"))
Expect(vg.FullyQualifiedDomainName).To(Equal("bosh-ecpi1.softlayer.com"))
Expect(vg.Hostname).To(Equal("bosh-ecpi1"))
Expect(vg.Id).To(Equal(1234567))
Expect(vg.LastPowerStateId).To(Equal(0))
Expect(vg.LastVerifiedDate).To(BeNil())
Expect(vg.MaxCpu).To(Equal(1))
Expect(vg.MaxCpuUnits).To(Equal("CORE"))
Expect(vg.MaxMemory).To(Equal(1024))
Expect(vg.MetricPollDate).To(BeNil())
示例3:
testhelpers.WaitForVirtualGuestToBeRunning(virtualGuest.Id)
testhelpers.WaitForVirtualGuestToHaveNoActiveTransactions(virtualGuest.Id)
virtualGuestService, err := testhelpers.CreateVirtualGuestService()
Expect(err).ToNot(HaveOccurred())
fmt.Printf("----> will attempt to upgrade virtual guest `%d`: [CPUs --> 2; RAM --> 2Gb; Network speed --> 1000]\n", virtualGuest.Id)
_, err = virtualGuestService.UpgradeObject(virtualGuest.Id, &softlayer.UpgradeOptions{
Cpus: 2,
MemoryInGB: 2,
NicSpeed: 1000,
})
Expect(err).ToNot(HaveOccurred())
fmt.Printf("----> verifying that upgrade successfully completed for virtual guest `%d`\n", virtualGuest.Id)
testhelpers.WaitForVirtualGuestTransactionWithStatus(virtualGuest.Id, "UPGRADE")
testhelpers.WaitForVirtualGuestToHaveNoActiveTransactions(virtualGuest.Id)
fmt.Printf("----> verify that cpu, ram and memory of virtual guest `%d` are upgraded\n", virtualGuest.Id)
upgradedVirtualGuest, err := virtualGuestService.GetObject(virtualGuest.Id)
Expect(err).ToNot(HaveOccurred())
Expect(upgradedVirtualGuest.MaxMemory).To(Equal(2048))
Expect(upgradedVirtualGuest.NetworkComponents[0].MaxSpeed).To(Equal(1000))
Expect(upgradedVirtualGuest.StartCpus).To(Equal(2))
fmt.Printf("----> successfully upgraded virtual guest `%d`\n", virtualGuest.Id)
})
})
})
示例4:
fs = fakesys.NewFakeFileSystem()
testhelpers.SetTestFixtureForFakeSoftLayerClient(softLayerClient, "SoftLayer_Virtual_Guest_Service_getObject.json")
})
Describe("Upload", func() {
It("file contents into /var/vcap/file.ext", func() {
expectedCmdResults := []string{
"",
}
testhelpers.SetTestFixturesForFakeSSHClient(sshClient, expectedCmdResults, nil)
var virtualGuestService softlayer.SoftLayer_Virtual_Guest_Service
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
Expect(err).ToNot(HaveOccurred())
virtualGuest, err := virtualGuestService.GetObject(1234567)
Expect(err).ToNot(HaveOccurred())
softlayerFileService = NewSoftlayerFileService(sshClient, virtualGuest, logger, uuidGenerator, fs)
err = softlayerFileService.Upload("/var/vcap/file.ext", []byte("fake-contents"))
Expect(err).ToNot(HaveOccurred())
})
})
Describe("Download", func() {
It("copies agent env into temporary location", func() {
expectedCmdResults := []string{
"",
}
testhelpers.SetTestFixturesForFakeSSHClient(sshClient, expectedCmdResults, nil)