• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang client.NewSoftLayerClient函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/maximilien/softlayer-go/client.NewSoftLayerClient函数的典型用法代码示例。如果您正苦于以下问题:Golang NewSoftLayerClient函数的具体用法?Golang NewSoftLayerClient怎么用?Golang NewSoftLayerClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewSoftLayerClient函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: CreateVirtualGuestService

func CreateVirtualGuestService() (softlayer.SoftLayer_Virtual_Guest_Service, error) {
	username, apiKey, err := GetUsernameAndApiKey()
	if err != nil {
		return nil, err
	}

	client := slclient.NewSoftLayerClient(username, apiKey)
	virtualGuestService, err := client.GetSoftLayer_Virtual_Guest_Service()
	if err != nil {
		return nil, err
	}

	return virtualGuestService, nil
}
开发者ID:digideskweb,项目名称:bosh-softlayer-cpi,代码行数:14,代码来源:test_helpers.go


示例17: CreateAccountService

func CreateAccountService() (softlayer.SoftLayer_Account_Service, error) {
	username, apiKey, err := GetUsernameAndApiKey()
	if err != nil {
		return nil, err
	}

	client := slclient.NewSoftLayerClient(username, apiKey)
	accountService, err := client.GetSoftLayer_Account_Service()
	if err != nil {
		return nil, err
	}

	return accountService, nil
}
开发者ID:digideskweb,项目名称:bosh-softlayer-cpi,代码行数:14,代码来源:test_helpers.go


示例18: Client

func (c *Config) Client() (*Client, error) {
	slc := slclient.NewSoftLayerClient(c.Username, c.ApiKey)
	virtualGuestService, err := slc.GetSoftLayer_Virtual_Guest_Service()

	if err != nil {
		return nil, err
	}

	sshKeyService, err := slc.GetSoftLayer_Security_Ssh_Key_Service()

	client := &Client{
		virtualGuestService: virtualGuestService,
		sshKeyService:       sshKeyService,
	}

	log.Println("[INFO] Created SoftLayer client")

	return client, nil
}
开发者ID:TheWeatherCompany,项目名称:terraform-provider-softlayer,代码行数:19,代码来源:config.go


示例19: VerifyCredential

// Verifies the given Softlayer credential.
// Compared against what is defined in schema.Credential.
func (s *Stack) VerifyCredential(c *stack.Credential) error {
	cred, ok := c.Credential.(*Credential)
	if !ok {
		return fmt.Errorf("credential is not of type softlayer.Credential: %T", c.Credential)
	}

	if err := cred.Valid(); err != nil {
		return err
	}

	// Do a quick check to verify the credentials are valid for
	// communitcating with the SoftLayer apis
	client := softlayer.NewSoftLayerClient(cred.Username, cred.ApiKey)
	account, err := client.GetSoftLayer_Account_Service()
	if err != nil {
		return err
	}

	_, err = account.GetAccountStatus()
	return err
}
开发者ID:koding,项目名称:koding,代码行数:23,代码来源:stack.go


示例20: New

// New creates new Softlayer command client.
func New(conf *SLConfig) (*SLImages, error) {
	// To suppress softlayer-go debug printfs...
	if err := os.Setenv("SL_GO_NON_VERBOSE", "YES"); err != nil {
		return nil, err
	}
	client := slclient.NewSoftLayerClient(conf.Username, conf.APIKey)
	account, err := client.GetSoftLayer_Account_Service()
	if err != nil {
		return nil, err
	}

	block, err := client.GetSoftLayer_Virtual_Guest_Block_Device_Template_Group_Service()
	if err != nil {
		return nil, err
	}

	return &SLImages{
		client:  client,
		account: account,
		block:   block,
	}, nil
}
开发者ID:rjeczalik,项目名称:images,代码行数:23,代码来源:sl.go



注:本文中的github.com/maximilien/softlayer-go/client.NewSoftLayerClient函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang fakes.NewFakeSoftLayerClient函数代码示例发布时间:2022-05-23
下一篇:
Golang fakes.FakeFinder类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap