Beispiel #1
0
func newClient() (*gophercloud.ServiceClient, error) {
	// Obtain credentials from the environment.
	options, err := rackspace.AuthOptionsFromEnv()
	if err != nil {
		return nil, err
	}
	options = tools.OnlyRS(options)
	region := os.Getenv("RS_REGION")

	if options.Username == "" {
		return nil, errors.New("Please provide a Rackspace username as RS_USERNAME.")
	}
	if options.APIKey == "" {
		return nil, errors.New("Please provide a Rackspace API key as RS_API_KEY.")
	}
	if region == "" {
		return nil, errors.New("Please provide a Rackspace region as RS_REGION.")
	}

	client, err := rackspace.AuthenticatedClient(options)
	if err != nil {
		return nil, err
	}

	return rackspace.NewComputeV2(client, gophercloud.EndpointOpts{
		Region: region,
	})
}
Beispiel #2
0
func newProvider() (*gophercloud.ProviderClient, error) {
	opts, err := rackspace.AuthOptionsFromEnv()
	if err != nil {
		return nil, err
	}
	opts = tools.OnlyRS(opts)

	return rackspace.AuthenticatedClient(opts)
}
Beispiel #3
0
func rackspaceAuthOptions(t *testing.T) gophercloud.AuthOptions {
	// Obtain credentials from the environment.
	options, err := rackspace.AuthOptionsFromEnv()
	th.AssertNoErr(t, err)
	options = tools.OnlyRS(options)

	if options.Username == "" {
		t.Fatal("Please provide a Rackspace username as RS_USERNAME.")
	}
	if options.APIKey == "" {
		t.Fatal("Please provide a Rackspace API key as RS_API_KEY.")
	}

	return options
}
Beispiel #4
0
func newClient(t *testing.T) *gophercloud.ServiceClient {
	opts, err := rackspace.AuthOptionsFromEnv()
	th.AssertNoErr(t, err)
	opts = tools.OnlyRS(opts)

	client, err := rackspace.AuthenticatedClient(opts)
	th.AssertNoErr(t, err)

	c, err := rackspace.NewDBV1(client, gophercloud.EndpointOpts{
		Region: "IAD",
	})
	th.AssertNoErr(t, err)

	return c
}
Beispiel #5
0
func TestAuthenticatedClient(t *testing.T) {
	// Obtain credentials from the environment.
	ao, err := rackspace.AuthOptionsFromEnv()
	th.AssertNoErr(t, err)

	client, err := rackspace.AuthenticatedClient(tools.OnlyRS(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)
}
Beispiel #6
0
func newClient() (*gophercloud.ServiceClient, error) {
	opts, err := rackspace.AuthOptionsFromEnv()
	if err != nil {
		return nil, err
	}
	opts = tools.OnlyRS(opts)
	region := os.Getenv("RS_REGION")

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

	return rackspace.NewBlockStorageV1(provider, gophercloud.EndpointOpts{
		Region: region,
	})
}