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


Golang client.NewSoftLayerClient函數代碼示例

本文整理匯總了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
}
開發者ID:cheyang,項目名稱:scloud,代碼行數:31,代碼來源:driver.go

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

示例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
}
開發者ID:cheyang,項目名稱:scloud,代碼行數:27,代碼來源:scloud.go

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

示例5: init

func init() {
	os.Unsetenv("SL_GO_NON_VERBOSE")

	opts.SLClient = slclient.NewSoftLayerClient(
		os.Getenv("KLOUD_TESTACCOUNT_SLUSERNAME"),
		os.Getenv("KLOUD_TESTACCOUNT_SLAPIKEY"),
	)
}
開發者ID:koding,項目名稱:koding,代碼行數:8,代碼來源:softlayer_test.go

示例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
}
開發者ID:cloudfoundry-community,項目名稱:bosh-softlayer-tools,代碼行數:13,代碼來源:stemcells.go

示例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
}
開發者ID:cheyang,項目名稱:scloud,代碼行數:13,代碼來源:list.go

示例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)
}
開發者ID:CloudCredo,項目名稱:bosh-lattice-cpi,代碼行數:13,代碼來源:main.go

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

示例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
}
開發者ID:mwright-pivotal,項目名稱:go_service_broker,代碼行數:13,代碼來源:softlayer.go

示例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
}
開發者ID:jianqiu,項目名稱:bosh-softlayer-cpi,代碼行數:14,代碼來源:test_helpers.go

示例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
}
開發者ID:digideskweb,項目名稱:bosh-softlayer-cpi,代碼行數:14,代碼來源:test_helpers.go

示例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
}
開發者ID:digideskweb,項目名稱:bosh-softlayer-cpi,代碼行數:14,代碼來源:test_helpers.go

示例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
}
開發者ID:digideskweb,項目名稱:bosh-softlayer-cpi,代碼行數:14,代碼來源:test_helpers.go

示例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
}
開發者ID:digideskweb,項目名稱:bosh-softlayer-cpi,代碼行數:14,代碼來源:test_helpers.go


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