当前位置: 首页>>代码示例>>Golang>>正文


Golang openstack.AuthenticatedClient函数代码示例

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


在下文中一共展示了AuthenticatedClient函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: newOpenstackClient

func newOpenstackClient(config *authConfig) (*OpenstackClient, error) {

	if config == nil {
		err := errors.New("no OpenStack cloud provider config file given")
		return nil, err
	}

	opts := gophercloud.AuthOptions{
		IdentityEndpoint: config.AuthUrl,
		Username:         config.Username,
		Password:         config.Password,
		TenantName:       config.Tenant,
		TenantID:         config.TenantID,
		AllowReauth:      false,
	}

	provider, err := openstack.AuthenticatedClient(opts)
	if err != nil {
		glog.Info("Failed: Starting openstack authenticate client")
		return nil, err
	}
	authClient := openstack.NewIdentityV2(provider)

	return &OpenstackClient{
		provider,
		authClient,
		config,
	}, nil
}
开发者ID:kuenzaa,项目名称:hypernetes,代码行数:29,代码来源:keystone.go

示例2: newCinderClient

func newCinderClient(configFile string) (*cinderClient, error) {
	cfg, err := readConfig(configFile)
	if err != nil {
		return nil, err
	}

	provider, err := openstack.AuthenticatedClient(cfg.toAuthOptions())
	if err != nil {
		return nil, err
	}

	client, err := openstack.NewBlockStorageV2(provider, gophercloud.EndpointOpts{
		Region: cfg.Global.Region,
	})
	if err != nil {
		return nil, err
	}

	cc := cinderClient{
		cinder:  client,
		keyring: cfg.RBD.Keyring,
	}

	return &cc, nil
}
开发者ID:thed00de,项目名称:hypernetes,代码行数:25,代码来源:cinder_client.go

示例3: TestAuthenticatedClient

func TestAuthenticatedClient(t *testing.T) {
	// Obtain credentials from the environment.
	ao, err := openstack.AuthOptionsFromEnv()
	if err != nil {
		t.Fatalf("Unable to acquire credentials: %v", err)
	}

	client, err := openstack.AuthenticatedClient(ao)
	if err != nil {
		t.Fatalf("Unable to authenticate: %v", err)
	}

	if client.TokenID == "" {
		t.Errorf("No token ID assigned to the client")
	}

	t.Logf("Client successfully acquired a token: %v", client.TokenID)

	// Find the storage service in the service catalog.
	storage, err := openstack.NewObjectStorageV1(client, gophercloud.EndpointOpts{
		Region: os.Getenv("OS_REGION_NAME"),
	})
	if err != nil {
		t.Errorf("Unable to locate a storage service: %v", err)
	} else {
		t.Logf("Located a storage service at endpoint: [%s]", storage.Endpoint)
	}
}
开发者ID:RomainVabre,项目名称:origin,代码行数:28,代码来源:client_test.go

示例4: client

func (c *Config) client() (*gophercloud.ProviderClient, error) {
	options := gophercloud.AuthOptions{
		IdentityEndpoint: fmt.Sprintf("https://identity.%s.conoha.io/v2.0", c.Region),
		Username:         c.Username,
		Password:         c.Password,
		TenantName:       c.TenantName,
	}

	return openstack.AuthenticatedClient(options)
}
开发者ID:hanazuki,项目名称:terraform-provider-conoha,代码行数:10,代码来源:config.go

示例5: Init

func (d *driver) Init(context types.Context, config gofig.Config) error {
	d.config = config

	fields := eff(map[string]interface{}{})
	var err error

	if d.instanceID, err = d.getInstanceID(); err != nil {
		return err
	}

	fields["moduleName"] = context
	fields["instanceId"] = d.instanceID

	if d.region, err = d.getInstanceRegion(); err != nil {
		return err
	}

	fields["region"] = d.region
	d.region = strings.ToUpper(d.region)

	authOpts := d.getAuthOptions()

	fields["identityEndpoint"] = d.authURL()
	fields["userId"] = d.userID()
	fields["userName"] = d.userName()
	if d.password() == "" {
		fields["password"] = ""
	} else {
		fields["password"] = "******"
	}
	fields["tenantId"] = d.tenantID()
	fields["tenantName"] = d.tenantName()
	fields["domainId"] = d.domainID()
	fields["domainName"] = d.domainName()

	if d.provider, err = openstack.AuthenticatedClient(authOpts); err != nil {
		return goof.WithFieldsE(fields,
			"error getting authenticated client", err)
	}

	if d.client, err = openstack.NewComputeV2(d.provider,
		gophercloud.EndpointOpts{Region: d.region}); err != nil {
		goof.WithFieldsE(fields, "error getting newComputeV2", err)
	}

	if d.clientBlockStorage, err = openstack.NewBlockStorageV1(d.provider,
		gophercloud.EndpointOpts{Region: d.region}); err != nil {
		return goof.WithFieldsE(fields,
			"error getting newBlockStorageV1", err)
	}

	log.WithFields(fields).Info("storage driver initialized")
	return nil

}
开发者ID:emccode,项目名称:libstorage,代码行数:55,代码来源:rackspace_storage.go

示例6: newClient

func newClient(t *testing.T) (*gophercloud.ServiceClient, error) {
	ao, err := openstack.AuthOptionsFromEnv()
	th.AssertNoErr(t, err)

	client, err := openstack.AuthenticatedClient(ao)
	th.AssertNoErr(t, err)

	return openstack.NewBlockStorageV2(client, gophercloud.EndpointOpts{
		Region: os.Getenv("OS_REGION_NAME"),
	})
}
开发者ID:sstrato,项目名称:gophercloud,代码行数:11,代码来源:volumeactions_test.go

示例7: Init

func (d *driver) Init(r *core.RexRay) error {
	d.r = r
	fields := ef()
	var err error

	if d.instanceID, err = getInstanceID(d.r.Config); err != nil {
		return err
	}

	fields["instanceId"] = d.instanceID

	if d.region, err = getInstanceRegion(d.r.Config); err != nil {
		return err
	}

	fields["region"] = d.region
	d.region = strings.ToUpper(d.region)

	authOpts := getAuthOptions(d.r.Config)

	fields["identityEndpoint"] = d.r.Config.RackspaceAuthURL
	fields["userId"] = d.r.Config.RackspaceUserID
	fields["userName"] = d.r.Config.RackspaceUserName
	if d.r.Config.RackspacePassword == "" {
		fields["password"] = ""
	} else {
		fields["password"] = "******"
	}
	fields["tenantId"] = d.r.Config.RackspaceTenantID
	fields["tenantName"] = d.r.Config.RackspaceTenantName
	fields["domainId"] = d.r.Config.RackspaceDomainID
	fields["domainName"] = d.r.Config.RackspaceDomainName

	if d.provider, err = openstack.AuthenticatedClient(authOpts); err != nil {
		return errors.WithFieldsE(fields,
			"error getting authenticated client", err)
	}

	if d.client, err = openstack.NewComputeV2(d.provider,
		gophercloud.EndpointOpts{Region: d.region}); err != nil {
		errors.WithFieldsE(fields, "error getting newComputeV2", err)
	}

	if d.clientBlockStorage, err = openstack.NewBlockStorageV1(d.provider,
		gophercloud.EndpointOpts{Region: d.region}); err != nil {
		return errors.WithFieldsE(fields,
			"error getting newBlockStorageV1", err)
	}

	log.WithField("provider", providerName).Info("storage driver initialized")

	return nil
}
开发者ID:moypray,项目名称:rexray,代码行数:53,代码来源:rackspace.go

示例8: getProviderClient

func getProviderClient() (*gophercloud.ProviderClient, error) {
	opts, err := openstack.AuthOptionsFromEnv()
	if err != nil {
		return nil, err
	}
	provider, err := openstack.AuthenticatedClient(opts)
	if err != nil {
		if strings.Contains(err.Error(), "provide exactly one of Domain") {
			return nil, fmt.Errorf(envVariablesNotSetError, keystoneDomainIDKey, keystoneDomainNameKey)
		}
	}
	return provider, err
}
开发者ID:gitter-badger,项目名称:gohan,代码行数:13,代码来源:client.go

示例9: newClient

func newClient(t *testing.T) *gophercloud.ServiceClient {
	ao, err := openstack.AuthOptionsFromEnv()
	th.AssertNoErr(t, err)

	client, err := openstack.AuthenticatedClient(ao)
	th.AssertNoErr(t, err)

	c, err := openstack.NewOrchestrationV1(client, gophercloud.EndpointOpts{
		Region: os.Getenv("OS_REGION_NAME"),
	})
	th.AssertNoErr(t, err)
	return c
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:13,代码来源:common.go

示例10: initIdentityClient

// initIdentityClient initializes openstack api using
// gophercloud which handles auth tokens keeping api calls
// simpler. Currently it uses environment variables for
// authenticating with openstack identity.
func initIdentityClient() (*gophercloud.ServiceClient, error) {
	opts, err := openstack.AuthOptionsFromEnv()
	if err != nil {
		log.Println("Error fetching openstack env vars: ", err)
		return nil, err
	}
	provider, err := openstack.AuthenticatedClient(opts)
	if err != nil {
		log.Println("Error authenticating with openstack: ", err)
		return nil, err
	}
	return openstack.NewIdentityV2(provider), nil
}
开发者ID:romana,项目名称:core,代码行数:17,代码来源:tenant.go

示例11: NewKeystoneClient

// NewKeystoneClient initilizes a keystone client with the provided configuration.
func NewKeystoneClient(config Config) (KeystoneClient, error) {
	opts := config.AuthOptions
	provider, err := openstack.AuthenticatedClient(opts)
	if err != nil {
		return nil, err
	}
	client := openstack.NewIdentityV3(provider)
	// build a closure for ksClient reauthentication
	client.ReauthFunc = func() error {
		return openstack.AuthenticateV3(client.ProviderClient, opts)
	}
	return &KeystoneClientImpl{client: client, opts: opts, token: nil, monascaURL: nil}, nil
}
开发者ID:titilambert,项目名称:heapster,代码行数:14,代码来源:keystone_client.go

示例12: newOpenStack

func newOpenStack(cfg Config) (*OpenStack, error) {
	provider, err := openstack.AuthenticatedClient(cfg.toAuthOptions())
	if err != nil {
		return nil, err
	}

	os := OpenStack{
		provider: provider,
		region:   cfg.Global.Region,
		lbOpts:   cfg.LoadBalancer,
	}
	return &os, nil
}
开发者ID:Tlacenka,项目名称:origin,代码行数:13,代码来源:openstack.go

示例13: initClient

func initClient(config *Config) (*gophercloud.ProviderClient, error) {
	opts := gophercloud.AuthOptions{
		IdentityEndpoint: config.Auth_Url,
		Username:         config.User,
		Password:         config.Password,
		TenantName:       config.Tenant,
	}
	client, err := openstack.AuthenticatedClient(opts)
	if err != nil {
		return nil, err
	}
	return client, nil
}
开发者ID:pyama86,项目名称:openstack-ssh,代码行数:13,代码来源:publickey.go

示例14: New

func New(cfgFile string) CinderDriver {
	conf, err := processConfig(cfgFile)
	isV3 := strings.Contains(conf.Endpoint, "v3")
	if err != nil {
		log.Fatal("Error processing cinder driver config file: ", err)
	}

	_, err = os.Lstat(conf.MountPoint)
	if os.IsNotExist(err) {
		if err := os.MkdirAll(conf.MountPoint, 0755); err != nil {
			log.Fatal("Failed to create Mount directory during driver init: %v", err)
		}
	}

	auth := gophercloud.AuthOptions{
		IdentityEndpoint: conf.Endpoint,
		Username:         conf.Username,
		Password:         conf.Password,
		TenantID:         conf.TenantID,
		AllowReauth:      true,
	}

	if isV3 == true && conf.DomainName == "" {
		log.Warning("V3 endpoint specified, but DomainName not set!")
		log.Warning("Setting to \"Default\", maybe it'll work.")
		auth.DomainName = "Default"
	}

	if conf.DomainName != "" && isV3 == true {
		log.Info("Authorizing to a V3 Endpoint")
		auth.DomainName = conf.DomainName
	}

	providerClient, err := openstack.AuthenticatedClient(auth)
	if err != nil {
		log.Fatal("Error initiating gophercloud provider client: ", err)
	}

	client, err := openstack.NewBlockStorageV2(providerClient,
		gophercloud.EndpointOpts{Region: "RegionOne"})
	if err != nil {
		log.Fatal("Error initiating gophercloud cinder client: ", err)
	}

	d := CinderDriver{
		Conf:   &conf,
		Mutex:  &sync.Mutex{},
		Client: client,
	}
	return d
}
开发者ID:j-griffith,项目名称:cinder-docker-driver,代码行数:51,代码来源:driver.go

示例15: networkingClient

func networkingClient() (*gophercloud.ServiceClient, error) {
	opts, err := openstack.AuthOptionsFromEnv()
	if err != nil {
		return nil, err
	}

	provider, err := openstack.AuthenticatedClient(opts)
	if err != nil {
		return nil, err
	}

	return openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{
		Region: os.Getenv("OS_REGION_NAME"),
	})
}
开发者ID:chenzhen411,项目名称:kubernetes,代码行数:15,代码来源:servers_test.go


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