Esempio n. 1
0
func MakeOpenStack(identityEndpoint string, username string, password string, tenantName string) (*OpenStack, error) {
	os := new(OpenStack)
	opts := gophercloud.AuthOptions{
		IdentityEndpoint: identityEndpoint,
		Username:         username,
		Password:         password,
		TenantName:       tenantName,
	}
	provider, err := openstack.AuthenticatedClient(opts)
	if err != nil {
		return nil, fmt.Errorf("openstack authentication error: %v", err)
	}
	os.ComputeClient, err = openstack.NewComputeV2(provider, gophercloud.EndpointOpts{})
	if err != nil {
		return nil, fmt.Errorf("compute client initialization error: %v", err)
	}
	os.ImageClient, err = openstack.NewImageV1(provider, gophercloud.EndpointOpts{})
	if err != nil {
		return nil, fmt.Errorf("image client initialization error: %v", err)
	}
	return os, nil
}
Esempio n. 2
0
func MakeOpenStack(identityEndpoint string, username string, password string, tenantName string, networkId string) *OpenStack {
	this := new(OpenStack)
	this.networkId = networkId
	opts := gophercloud.AuthOptions{
		IdentityEndpoint: identityEndpoint,
		Username:         username,
		Password:         password,
		TenantName:       tenantName,
	}
	provider, err := openstack.AuthenticatedClient(opts)
	if err != nil {
		panic(err)
	}
	this.ComputeClient, err = openstack.NewComputeV2(provider, gophercloud.EndpointOpts{})
	if err != nil {
		panic(err)
	}
	this.ImageClient, err = openstack.NewImageV1(provider, gophercloud.EndpointOpts{})
	if err != nil {
		panic(err)
	}
	return this
}