本文整理汇总了Golang中github.com/maximilien/softlayer-go/softlayer.Client类的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: WaitForVirtualGuest
func WaitForVirtualGuest(softLayerClient sl.Client, virtualGuestId int, targetState string, timeout, pollingInterval time.Duration) error {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapError(err, "Creating VirtualGuestService from SoftLayer client")
}
retryCount := 0
totalTime := time.Duration(0)
for totalTime < timeout {
vgPowerState, err := virtualGuestService.GetPowerState(virtualGuestId)
if err != nil {
if retryCount > MAX_RETRY_COUNT {
return bosherr.WrapError(err, "Getting active transactions from SoftLayer client")
} else {
retryCount += 1
continue
}
}
if vgPowerState.KeyName == targetState {
return nil
}
totalTime += pollingInterval
time.Sleep(pollingInterval)
}
return bosherr.Errorf("Waiting for virtual guest with ID '%d' to have be in state '%s'", virtualGuestId, targetState)
}
开发者ID:CloudCredo,项目名称:bosh-lattice-cpi,代码行数:29,代码来源:softlayer_helper.go
示例2: WaitForVirtualGuestToTargetState
func WaitForVirtualGuestToTargetState(softLayerClient sl.Client, virtualGuestId int, targetState string, logger boshlog.Logger) error {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapError(err, "Creating VirtualGuestService from SoftLayer client")
}
getTargetStateRetryable := boshretry.NewRetryable(
func() (bool, error) {
vgPowerState, err := virtualGuestService.GetPowerState(virtualGuestId)
if err != nil {
return false, bosherr.WrapErrorf(err, "Getting PowerState from vitrual guest %d", virtualGuestId)
} else {
if strings.Contains(vgPowerState.KeyName, targetState) {
return false, nil
}
return true, nil
}
})
timeService := clock.NewClock()
timeoutRetryStrategy := boshretry.NewTimeoutRetryStrategy(TIMEOUT, POLLING_INTERVAL, getTargetStateRetryable, timeService, logger)
err = timeoutRetryStrategy.Try()
if err != nil {
return bosherr.Errorf("Waiting for virtual guest with ID '%d' to have be in state '%s'", virtualGuestId, targetState)
}
return nil
}
开发者ID:ardnaxelarak,项目名称:bosh-softlayer-cpi,代码行数:28,代码来源:softlayer_helper.go
示例3: WaitForVirtualGuestToHaveNoRunningTransaction
func WaitForVirtualGuestToHaveNoRunningTransaction(softLayerClient sl.Client, virtualGuestId int, logger boshlog.Logger) error {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapError(err, "Creating VirtualGuestService from SoftLayer client")
}
totalTime := time.Duration(0)
for totalTime < TIMEOUT {
activeTransactions, err := virtualGuestService.GetActiveTransactions(virtualGuestId)
if err != nil {
return bosherr.WrapErrorf(err, "Getting active transaction against vitrual guest %d", virtualGuestId)
}
if len(activeTransactions) == 0 {
return nil
}
totalTime += POLLING_INTERVAL
time.Sleep(POLLING_INTERVAL)
}
return bosherr.Errorf("Waiting for virtual guest with ID '%d' to have no active transactions", virtualGuestId)
}
开发者ID:digideskweb,项目名称:bosh-softlayer-cpi,代码行数:25,代码来源:softlayer_helper.go
示例4: WaitForVirtualGuestToHaveNoRunningTransactions
func WaitForVirtualGuestToHaveNoRunningTransactions(softLayerClient sl.Client, virtualGuestId int, timeout, pollingInterval time.Duration) error {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapError(err, "Creating VirtualGuestService from SoftLayer client")
}
retryCount := 0
totalTime := time.Duration(0)
for totalTime < timeout {
activeTransactions, err := virtualGuestService.GetActiveTransactions(virtualGuestId)
if err != nil {
if retryCount > MAX_RETRY_COUNT {
return bosherr.WrapError(err, "Getting active transactions from SoftLayer client")
} else {
retryCount += 1
continue
}
}
if len(activeTransactions) == 0 {
return nil
}
totalTime += pollingInterval
time.Sleep(pollingInterval)
}
return bosherr.Errorf("Waiting for virtual guest with ID '%d' to have no active transactions", virtualGuestId)
}
开发者ID:CloudCredo,项目名称:bosh-lattice-cpi,代码行数:29,代码来源:softlayer_helper.go
示例5: AttachEphemeralDiskToVirtualGuest
func AttachEphemeralDiskToVirtualGuest(softLayerClient sl.Client, virtualGuestId int, diskSize int, logger boshlog.Logger) error {
err := WaitForVirtualGuestLastCompleteTransaction(softLayerClient, virtualGuestId, "Service Setup")
if err != nil {
return bosherr.WrapErrorf(err, "Waiting for VirtualGuest `%d` has Service Setup transaction complete", virtualGuestId)
}
err = WaitForVirtualGuestToHaveNoRunningTransactions(softLayerClient, virtualGuestId)
if err != nil {
return bosherr.WrapErrorf(err, "Waiting for VirtualGuest `%d` to have no pending transactions", virtualGuestId)
}
service, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapErrorf(err, "Attaching ephemeral disk to VirtualGuest `%d`", virtualGuestId)
}
err = service.AttachEphemeralDisk(virtualGuestId, diskSize)
if err != nil {
return bosherr.WrapErrorf(err, "Attaching ephemeral disk to VirtualGuest `%d`", virtualGuestId)
}
err = WaitForVirtualGuestToHaveRunningTransaction(softLayerClient, virtualGuestId, logger)
if err != nil {
return bosherr.WrapErrorf(err, "Waiting for VirtualGuest `%d` to launch transaction", virtualGuestId)
}
err = WaitForVirtualGuestLastCompleteTransaction(softLayerClient, virtualGuestId, "Cloud Instance Upgrade")
if err != nil {
return bosherr.WrapErrorf(err, "Waiting for VirtualGuest `%d` has Cloud Instance Upgrade transaction complete", virtualGuestId)
}
return nil
}
开发者ID:ardnaxelarak,项目名称:bosh-softlayer-cpi,代码行数:33,代码来源:softlayer_helper.go
示例6: WaitForVirtualGuestIsNotPingable
func WaitForVirtualGuestIsNotPingable(softLayerClient sl.Client, virtualGuestId int, logger boshlog.Logger) error {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapError(err, "Creating VirtualGuestService from SoftLayer client")
}
checkPingableRetryable := boshretry.NewRetryable(
func() (bool, error) {
state, err := virtualGuestService.IsPingable(virtualGuestId)
if err != nil {
return false, bosherr.WrapErrorf(err, "Checking pingable against vitrual guest %d", virtualGuestId)
} else {
return state, nil
}
})
timeService := clock.NewClock()
timeoutRetryStrategy := boshretry.NewTimeoutRetryStrategy(TIMEOUT, POLLING_INTERVAL, checkPingableRetryable, timeService, logger)
err = timeoutRetryStrategy.Try()
if err != nil {
return bosherr.Errorf("Waiting for virtual guest with ID '%d' is not pingable", virtualGuestId)
}
return nil
}
开发者ID:ardnaxelarak,项目名称:bosh-softlayer-cpi,代码行数:25,代码来源:softlayer_helper.go
示例7: postCheckActiveTransactionsForOSReload
func (vm SoftLayerVM) postCheckActiveTransactionsForOSReload(softLayerClient sl.Client) error {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapError(err, "Creating VirtualGuestService from SoftLayer client")
}
totalTime := time.Duration(0)
for totalTime < bslcommon.TIMEOUT {
activeTransactions, err := virtualGuestService.GetActiveTransactions(vm.ID())
if err != nil {
return bosherr.WrapError(err, "Getting active transactions from SoftLayer client")
}
if len(activeTransactions) > 0 {
vm.logger.Info(SOFTLAYER_VM_OS_RELOAD_TAG, "OS Reload transaction started")
break
}
totalTime += bslcommon.POLLING_INTERVAL
time.Sleep(bslcommon.POLLING_INTERVAL)
}
if totalTime >= bslcommon.TIMEOUT {
return errors.New(fmt.Sprintf("Waiting for OS Reload transaction to start TIME OUT!"))
}
err = bslcommon.WaitForVirtualGuest(vm.softLayerClient, vm.ID(), "RUNNING")
if err != nil {
return bosherr.WrapError(err, fmt.Sprintf("PowerOn failed with VirtualGuest id %d", vm.ID()))
}
vm.logger.Info(SOFTLAYER_VM_OS_RELOAD_TAG, fmt.Sprintf("The virtual guest %d is powered on", vm.ID()))
return nil
}
开发者ID:digideskweb,项目名称:bosh-softlayer-cpi,代码行数:35,代码来源:softlayer_vm.go
示例8: WaitForVirtualGuestToHaveNoRunningTransaction
func WaitForVirtualGuestToHaveNoRunningTransaction(softLayerClient sl.Client, virtualGuestId int, logger boshlog.Logger) error {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapError(err, "Creating VirtualGuestService from SoftLayer client")
}
runningTransactionsRetryable := boshretry.NewRetryable(
func() (bool, error) {
activeTransactions, err := virtualGuestService.GetActiveTransactions(virtualGuestId)
if err != nil {
return false, bosherr.WrapErrorf(err, "Getting active transaction against vitrual guest %d", virtualGuestId)
} else {
if len(activeTransactions) == 0 {
return false, nil
}
return true, nil
}
})
timeService := clock.NewClock()
timeoutRetryStrategy := boshretry.NewTimeoutRetryStrategy(TIMEOUT, POLLING_INTERVAL, runningTransactionsRetryable, timeService, logger)
err = timeoutRetryStrategy.Try()
if err != nil {
return bosherr.Errorf("Waiting for virtual guest with ID '%d' to have no active transactions", virtualGuestId)
}
return nil
}
开发者ID:ardnaxelarak,项目名称:bosh-softlayer-cpi,代码行数:28,代码来源:softlayer_helper.go
示例9: WaitForVirtualGuestUpgradeComplete
func WaitForVirtualGuestUpgradeComplete(softLayerClient sl.Client, virtualGuestId int) error {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapError(err, "Creating VirtualGuestService from SoftLayer client")
}
totalTime := time.Duration(0)
for totalTime < TIMEOUT {
lastTransaction, err := virtualGuestService.GetLastTransaction(virtualGuestId)
if err != nil {
return bosherr.WrapErrorf(err, "Getting Last Complete Transaction for virtual guest with ID '%d'", virtualGuestId)
}
if strings.Contains(lastTransaction.TransactionGroup.Name, "Cloud Migrate") && strings.Contains(lastTransaction.TransactionStatus.FriendlyName, "Complete") {
return nil
}
if strings.Contains(lastTransaction.TransactionGroup.Name, "Cloud Instance Upgrade") && strings.Contains(lastTransaction.TransactionStatus.FriendlyName, "Complete") {
return nil
}
totalTime += POLLING_INTERVAL
time.Sleep(POLLING_INTERVAL)
}
return bosherr.Errorf("Waiting for virtual guest with ID '%d' to update complete", virtualGuestId)
}
开发者ID:digideskweb,项目名称:bosh-softlayer-cpi,代码行数:27,代码来源:softlayer_helper.go
示例10: GetObjectDetailsOnVirtualGuest
func GetObjectDetailsOnVirtualGuest(softLayerClient sl.Client, virtualGuestId int) (datatypes.SoftLayer_Virtual_Guest, error) {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return datatypes.SoftLayer_Virtual_Guest{}, bosherr.WrapError(err, "Cannot get softlayer virtual guest service.")
}
virtualGuest, err := virtualGuestService.GetObject(virtualGuestId)
if err != nil {
return datatypes.SoftLayer_Virtual_Guest{}, bosherr.WrapErrorf(err, "Cannot get virtual guest with id: %d", virtualGuestId)
}
return virtualGuest, nil
}
开发者ID:ardnaxelarak,项目名称:bosh-softlayer-cpi,代码行数:11,代码来源:softlayer_helper.go
示例11: ConfigureMetadataDiskOnVirtualGuest
func ConfigureMetadataDiskOnVirtualGuest(softLayerClient sl.Client, virtualGuestId int) error {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapError(err, "Creating VirtualGuestService from SoftLayer client")
}
_, err = virtualGuestService.ConfigureMetadataDisk(virtualGuestId)
if err != nil {
return bosherr.WrapError(err, fmt.Sprintf("Configuring metadata on VirtualGuest `%d`", virtualGuestId))
}
return nil
}
开发者ID:CloudCredo,项目名称:bosh-lattice-cpi,代码行数:13,代码来源:softlayer_helper.go
示例12: GetObjectDetailsOnStorage
func GetObjectDetailsOnStorage(softLayerClient sl.Client, volumeId int) (datatypes.SoftLayer_Network_Storage, error) {
networkStorageService, err := softLayerClient.GetSoftLayer_Network_Storage_Service()
if err != nil {
return datatypes.SoftLayer_Network_Storage{}, bosherr.WrapError(err, "Cannot get network storage service.")
}
volume, err := networkStorageService.GetIscsiVolume(volumeId)
if err != nil {
return datatypes.SoftLayer_Network_Storage{}, bosherr.WrapErrorf(err, "Cannot get iSCSI volume with id: %d", volumeId)
}
return volume, nil
}
开发者ID:ardnaxelarak,项目名称:bosh-softlayer-cpi,代码行数:13,代码来源:softlayer_helper.go
示例13: AttachEphemeralDiskToVirtualGuest
func AttachEphemeralDiskToVirtualGuest(softLayerClient sl.Client, virtualGuestId int, diskSize int, logger boshlog.Logger) error {
err := WaitForVirtualGuestLastCompleteTransaction(softLayerClient, virtualGuestId, "Service Setup")
if err != nil {
return bosherr.WrapErrorf(err, "Waiting for VirtualGuest `%d` has Service Setup transaction complete", virtualGuestId)
}
err = WaitForVirtualGuestToHaveNoRunningTransactions(softLayerClient, virtualGuestId)
if err != nil {
return bosherr.WrapErrorf(err, "Waiting for VirtualGuest `%d` to have no pending transactions", virtualGuestId)
}
service, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapErrorf(err, "Attaching ephemeral disk to VirtualGuest `%d`", virtualGuestId)
}
receipt, err := service.AttachEphemeralDisk(virtualGuestId, diskSize)
if err != nil {
if !strings.Contains(err.Error(), "HTTP error code") {
return err
}
}
if receipt.OrderId == 0 {
return nil
}
err = WaitForVirtualGuestToHaveRunningTransaction(softLayerClient, virtualGuestId, logger)
if err != nil {
return bosherr.WrapErrorf(err, "Waiting for VirtualGuest `%d` to launch transaction", virtualGuestId)
}
err = WaitForVirtualGuestToHaveNoRunningTransaction(softLayerClient, virtualGuestId, logger)
if err != nil {
return bosherr.WrapErrorf(err, "Waiting for VirtualGuest `%d` no transcation in progress", virtualGuestId)
}
err = WaitForVirtualGuestUpgradeComplete(softLayerClient, virtualGuestId)
if err != nil {
return bosherr.WrapErrorf(err, "Waiting for VirtualGuest `%d` upgrade complete", virtualGuestId)
}
err = WaitForVirtualGuest(softLayerClient, virtualGuestId, "RUNNING")
if err != nil {
return bosherr.WrapErrorf(err, "Waiting for VirtualGuest `%d`", virtualGuestId)
}
return nil
}
开发者ID:jianqiu,项目名称:bosh-softlayer-cpi,代码行数:50,代码来源:softlayer_helper.go
示例14: SetMetadataOnVirtualGuest
func SetMetadataOnVirtualGuest(softLayerClient sl.Client, virtualGuestId int, metadata string) error {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapError(err, "Creating VirtualGuestService from SoftLayer client")
}
success, err := virtualGuestService.SetMetadata(virtualGuestId, metadata)
if err != nil {
return bosherr.WrapError(err, fmt.Sprintf("Setting metadata on VirtualGuest `%d`", virtualGuestId))
}
if !success {
return bosherr.WrapError(err, fmt.Sprintf("Failed to set metadata on VirtualGuest `%d`", virtualGuestId))
}
return nil
}
开发者ID:CloudCredo,项目名称:bosh-lattice-cpi,代码行数:17,代码来源:softlayer_helper.go
示例15: WaitForVirtualGuest
func WaitForVirtualGuest(softLayerClient sl.Client, virtualGuestId int, targetState string) error {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapError(err, "Creating VirtualGuestService from SoftLayer client")
}
totalTime := time.Duration(0)
for totalTime < TIMEOUT {
vgPowerState, err := virtualGuestService.GetPowerState(virtualGuestId)
if err != nil {
return bosherr.WrapErrorf(err, "Getting Power State for virtual guest with ID '%d'", virtualGuestId)
}
if strings.Contains(vgPowerState.KeyName, targetState) {
return nil
}
totalTime += POLLING_INTERVAL
time.Sleep(POLLING_INTERVAL)
}
return bosherr.Errorf("Waiting for virtual guest with ID '%d' to have be in state '%s'", virtualGuestId, targetState)
}
开发者ID:ardnaxelarak,项目名称:bosh-softlayer-cpi,代码行数:23,代码来源:softlayer_helper.go
示例16: GetUserMetadataOnVirtualGuest
func GetUserMetadataOnVirtualGuest(softLayerClient sl.Client, virtualGuestId int) ([]byte, error) {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return []byte{}, bosherr.WrapError(err, "Creating VirtualGuestService from SoftLayer client")
}
attributes, err := virtualGuestService.GetUserData(virtualGuestId)
if err != nil {
return []byte{}, bosherr.WrapErrorf(err, "Getting metadata on VirtualGuest `%d`", virtualGuestId)
}
if len(attributes) == 0 {
return []byte{}, bosherr.WrapErrorf(err, "Failed to get metadata on VirtualGuest `%d`", virtualGuestId)
}
sEnc := attributes[0].Value
sDec, err := base64.StdEncoding.DecodeString(sEnc)
if err != nil {
return []byte{}, bosherr.WrapErrorf(err, "Failed to decode metadata returned from virtualGuest `%d`", virtualGuestId)
}
return sDec, nil
}
开发者ID:ardnaxelarak,项目名称:bosh-softlayer-cpi,代码行数:23,代码来源:softlayer_helper.go
示例17: AttachEphemeralDiskToVirtualGuest
func AttachEphemeralDiskToVirtualGuest(softLayerClient sl.Client, virtualGuestId int, diskSize int, timeout, pollingInterval time.Duration) error {
err := WaitForVirtualGuest(softLayerClient, virtualGuestId, "RUNNING", timeout, pollingInterval)
if err != nil {
return bosherr.WrapError(err, fmt.Sprintf("Waiting for VirtualGuest `%d`", virtualGuestId))
}
err = WaitForVirtualGuestToHaveNoRunningTransactions(softLayerClient, virtualGuestId, timeout, pollingInterval)
if err != nil {
return bosherr.WrapError(err, fmt.Sprintf("Waiting for VirtualGuest `%d` to have no pending transactions", virtualGuestId))
}
service, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapError(err, fmt.Sprintf("Attaching ephemeral disk to VirtualGuest `%d`", virtualGuestId))
}
err = service.AttachEphemeralDisk(virtualGuestId, diskSize)
if err != nil {
return bosherr.WrapError(err, fmt.Sprintf("Attaching ephemeral disk to VirtualGuest `%d`", virtualGuestId))
}
return nil
}
开发者ID:CloudCredo,项目名称:bosh-lattice-cpi,代码行数:23,代码来源:softlayer_helper.go
示例18:
softlayer "github.com/maximilien/softlayer-go/softlayer"
testhelpers "github.com/maximilien/softlayer-go/test_helpers"
)
const configPath = "test_fixtures/cpi_methods/config.json"
var _ = Describe("BOSH Director Level Integration for delete_stemcell", func() {
var (
err error
client softlayer.Client
username, apiKey string
vgbdtgService softlayer.SoftLayer_Virtual_Guest_Block_Device_Template_Group_Service
configuration datatypes.SoftLayer_Container_Virtual_Guest_Block_Device_Template_Configuration
rootTemplatePath, tmpConfigPath string
virtual_disk_image_id int
output map[string]interface{}
replacementMap map[string]string
)
BeforeEach(func() {
username = os.Getenv("SL_USERNAME")
Expect(username).ToNot(Equal(""), "username cannot be empty, set SL_USERNAME")
apiKey = os.Getenv("SL_API_KEY")
Expect(apiKey).ToNot(Equal(""), "apiKey cannot be empty, set SL_API_KEY")
开发者ID:jianqiu,项目名称:bosh-softlayer-cpi,代码行数:32,代码来源:delete_stemcell_test.go
示例19: postCheckActiveTransactionsForDeleteVM
func (vm SoftLayerVM) postCheckActiveTransactionsForDeleteVM(softLayerClient sl.Client, virtualGuestId int) error {
virtualGuestService, err := softLayerClient.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return bosherr.WrapError(err, "Creating VirtualGuestService from SoftLayer client")
}
totalTime := time.Duration(0)
for totalTime < bslcommon.TIMEOUT {
activeTransactions, err := virtualGuestService.GetActiveTransactions(virtualGuestId)
if err != nil {
return bosherr.WrapError(err, "Getting active transactions from SoftLayer client")
}
if len(activeTransactions) > 0 {
vm.logger.Info(SOFTLAYER_VM_LOG_TAG, "Delete VM transaction started", nil)
break
}
totalTime += bslcommon.POLLING_INTERVAL
time.Sleep(bslcommon.POLLING_INTERVAL)
}
if totalTime >= bslcommon.TIMEOUT {
return errors.New(fmt.Sprintf("Waiting for DeleteVM transaction to start TIME OUT!"))
}
totalTime = time.Duration(0)
for totalTime < bslcommon.TIMEOUT {
vm1, err := virtualGuestService.GetObject(virtualGuestId)
if err != nil || vm1.Id == 0 {
vm.logger.Info(SOFTLAYER_VM_LOG_TAG, "VM doesn't exist. Delete done", nil)
break
}
activeTransaction, err := virtualGuestService.GetActiveTransaction(virtualGuestId)
if err != nil {
return bosherr.WrapError(err, "Getting active transactions from SoftLayer client")
}
averageDuration := activeTransaction.TransactionStatus.AverageDuration
if strings.HasPrefix(averageDuration, ".") || averageDuration == "" {
averageDuration = "0" + averageDuration
}
averageTransactionDuration, err := strconv.ParseFloat(averageDuration, 32)
if err != nil {
averageTransactionDuration = 0
}
if averageTransactionDuration > 30 {
vm.logger.Info(SOFTLAYER_VM_LOG_TAG, "Deleting VM instance had been launched and it is a long transaction. Please check Softlayer Portal", nil)
break
}
vm.logger.Info(SOFTLAYER_VM_LOG_TAG, "This is a short transaction, waiting for all active transactions to complete", nil)
totalTime += bslcommon.POLLING_INTERVAL
time.Sleep(bslcommon.POLLING_INTERVAL)
}
if totalTime >= bslcommon.TIMEOUT {
return errors.New(fmt.Sprintf("After deleting a vm, waiting for active transactions to complete TIME OUT!"))
}
return nil
}
开发者ID:digideskweb,项目名称:bosh-softlayer-cpi,代码行数:65,代码来源:softlayer_vm.go
示例20:
package client_test
import (
"os"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
slclient "github.com/maximilien/softlayer-go/client"
softlayer "github.com/maximilien/softlayer-go/softlayer"
)
var _ = Describe("SoftLayerClient", func() {
var (
username string
apiKey string
client softlayer.Client
)
BeforeEach(func() {
username = os.Getenv("SL_USERNAME")
apiKey = os.Getenv("SL_API_KEY")
client = slclient.NewSoftLayerClient(username, apiKey)
})
Context("#NewSoftLayerClient", func() {
It("creates a new client with username and apiKey", func() {
Expect(username).ToNot(Equal(""), "username cannot be empty, set SL_USERNAME")
Expect(apiKey).ToNot(Equal(""), "apiKey cannot be empty, set SL_API_KEY")
开发者ID:jianqiu,项目名称:softlayer-go,代码行数:31,代码来源:softlayer_client_test.go
注:本文中的github.com/maximilien/softlayer-go/softlayer.Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论