当前位置: 首页>>代码示例>>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;未经允许,请勿转载。