本文整理汇总了Golang中github.com/maximilien/softlayer-go/client.NewSoftLayerClient函数的典型用法代码示例。如果您正苦于以下问题:Golang NewSoftLayerClient函数的具体用法?Golang NewSoftLayerClient怎么用?Golang NewSoftLayerClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewSoftLayerClient函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: setup
func setup() {
apiUser := os.Getenv("SL_API_USER")
apiKey := os.Getenv("SL_API_KEY")
if apiUser == "" || apiKey == "" {
fmt.Println("Please don't forget to set SL_API_USER and SL_API_KEY before running command")
return
}
apiClient = slclient.NewSoftLayerClient(apiUser, apiKey)
accountService, err := apiClient.GetSoftLayer_Account_Service()
if err != nil {
fmt.Fprintf(os.Stderr, "Init sl cloud failed due to %s \n", err)
return
}
accountStatus, err := accountService.GetAccountStatus()
if err != nil {
fmt.Fprintf(os.Stderr, "Init sl cloud failed due to %s \n", err)
return
} else if strings.ToLower(accountStatus.Name) != "active" {
fmt.Fprintf(os.Stderr, "Account status is %s, not as Active expected \n", accountStatus.Name)
return
}
initDone = true
}
示例2: NewSoftlayer
// NewSoftlayer creates new Softlayer client for the given credentials.
func NewSoftlayer(username, apiKey string) *Softlayer {
client := client.NewSoftLayerClient(username, apiKey)
opts := &Options{
SLClient: client,
}
return NewSoftlayerWithOptions(opts)
}
示例3: FindHostname
func FindHostname(hostname string) (bool, error) {
apiUser := os.Getenv(ApiUser)
apiKey := os.Getenv(ApiKey)
client := slclient.NewSoftLayerClient(apiUser, apiKey)
accountService, err := client.GetSoftLayer_Account_Service()
if err != nil {
return false, err
}
virtualGuests, err := accountService.GetVirtualGuests()
if err != nil {
return false, err
}
for _, guest := range virtualGuests {
if strings.Contains(guest.Hostname, hostname) {
fmt.Printf("Found guest %v ")
return true, nil
}
}
return true, nil
}
示例4: main
func main() {
apiUser := os.Getenv(ApiUser)
apiKey := os.Getenv(ApiKey)
id := 12345
client := slclient.NewSoftLayerClient(apiUser, apiKey)
virtualGuestService, err := client.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
fmt.Println(err)
return
} else {
fmt.Println("No error found in client.GetSoftLayer_Virtual_Guest_Service()")
}
virtualGuest, err := virtualGuestService.GetObject(id)
if err != nil {
fmt.Println("errors:", err)
return
} else {
fmt.Println("No error found in virtualGuestService.GetObject(id)")
}
spew.Printf("virtualGuest =%#+v\n", virtualGuest)
vgPowerState, err := virtualGuestService.GetPowerState(id)
spew.Printf("vgPowerState =%#+v\n", vgPowerState)
}
示例5: init
func init() {
os.Unsetenv("SL_GO_NON_VERBOSE")
opts.SLClient = slclient.NewSoftLayerClient(
os.Getenv("KLOUD_TESTACCOUNT_SLUSERNAME"),
os.Getenv("KLOUD_TESTACCOUNT_SLAPIKEY"),
)
}
示例6: createSoftLayerClient
func createSoftLayerClient() (softlayer.Client, error) {
username := os.Getenv("SL_USERNAME")
if username == "" {
return nil, errors.New("stemcells: cannot create SoftLayer client: SL_USERNAME environment variable must be set")
}
apiKey := os.Getenv("SL_API_KEY")
if apiKey == "" {
return nil, errors.New("stemcells: cannot create SoftLayer client: SL_API_KEY environment variable must be set")
}
return slclient.NewSoftLayerClient(username, apiKey), nil
}
示例7: GetClient
func GetClient() (softlayer.Client, error) {
apiUser := os.Getenv("SL_API_USER")
apiKey := os.Getenv("SL_API_KEY")
if apiUser == "" || apiKey == "" {
fmt.Println("Please don't forget to set SL_API_USER and SL_API_KEY before running command")
return nil, fmt.Errorf("apiUser and key are not setting.")
}
return slclient.NewSoftLayerClient(apiUser, apiKey), nil
}
示例8: buildDispatcher
func buildDispatcher(config Config, logger boshlog.Logger, fs boshsys.FileSystem, cmdRunner boshsys.CmdRunner) bslcdisp.Dispatcher {
softLayerClient := slclient.NewSoftLayerClient(config.SoftLayer.Username, config.SoftLayer.ApiKey)
actionFactory := bslcaction.NewConcreteFactory(
softLayerClient,
config.Actions,
logger,
)
caller := bslcdisp.NewJSONCaller()
return bslcdisp.NewJSON(actionFactory, caller, logger)
}
示例9: NewMachine
// Uses credentials provided during stack build to create
// a Softlayer machine representation and it's client
func NewMachine(bm *provider.BaseMachine) (provider.Machine, error) {
c, ok := bm.Credential.(*Credential)
if !ok {
return nil, errors.New("not a valid Soflayer credential")
}
m := &Machine{
BaseMachine: bm,
Client: softlayerGo.NewSoftLayerClient(c.Username, c.ApiKey),
}
return m, nil
}
示例10: createSoftLayerClient
func (c *SoftLayerClient) createSoftLayerClient() (softlayer.Client, error) {
username := os.Getenv("SL_USERNAME")
if username == "" {
return nil, errors.New("You must set environment variable SL_USERNAME for SoftLayer cloud")
}
apiKey := os.Getenv("SL_API_KEY")
if apiKey == "" {
return nil, errors.New("You must set environment variable SL_API_KEY for SoftLayer cloud")
}
return slclient.NewSoftLayerClient(username, apiKey), nil
}
示例11: CreateDnsDomainResourceRecordService
func CreateDnsDomainResourceRecordService() (softlayer.SoftLayer_Dns_Domain_ResourceRecord_Service, error) {
username, apiKey, err := GetUsernameAndApiKey()
if err != nil {
return nil, err
}
client := slclient.NewSoftLayerClient(username, apiKey)
dnsDomainResourceRecordService, err := client.GetSoftLayer_Dns_Domain_ResourceRecord_Service()
if err != nil {
return nil, err
}
return dnsDomainResourceRecordService, nil
}
示例12: CreateNetworkStorageService
func CreateNetworkStorageService() (softlayer.SoftLayer_Network_Storage_Service, error) {
username, apiKey, err := GetUsernameAndApiKey()
if err != nil {
return nil, err
}
client := slclient.NewSoftLayerClient(username, apiKey)
networkStorageService, err := client.GetSoftLayer_Network_Storage_Service()
if err != nil {
return nil, err
}
return networkStorageService, nil
}
示例13: CreateProductPackageService
func CreateProductPackageService() (softlayer.SoftLayer_Product_Package_Service, error) {
username, apiKey, err := GetUsernameAndApiKey()
if err != nil {
return nil, err
}
client := slclient.NewSoftLayerClient(username, apiKey)
productPackageService, err := client.GetSoftLayer_Product_Package_Service()
if err != nil {
return nil, err
}
return productPackageService, nil
}
示例14: CreateSecuritySshKeyService
func CreateSecuritySshKeyService() (softlayer.SoftLayer_Security_Ssh_Key_Service, error) {
username, apiKey, err := GetUsernameAndApiKey()
if err != nil {
return nil, err
}
client := slclient.NewSoftLayerClient(username, apiKey)
sshKeyService, err := client.GetSoftLayer_Security_Ssh_Key_Service()
if err != nil {
return nil, err
}
return sshKeyService, nil
}
示例15: CreateVirtualGuestBlockDeviceTemplateGroupService
func CreateVirtualGuestBlockDeviceTemplateGroupService() (softlayer.SoftLayer_Virtual_Guest_Block_Device_Template_Group_Service, error) {
username, apiKey, err := GetUsernameAndApiKey()
if err != nil {
return nil, err
}
client := slclient.NewSoftLayerClient(username, apiKey)
vgbdtgService, err := client.GetSoftLayer_Virtual_Guest_Block_Device_Template_Group_Service()
if err != nil {
return nil, err
}
return vgbdtgService, nil
}