Esempio n. 1
0
func newOpenstackStorageAdapter(environConfig *config.Config) (openstackStorage, error) {
	ecfg, err := providerInstance.newConfig(environConfig)
	if err != nil {
		return nil, errors.Trace(err)
	}
	client, err := authClient(ecfg)
	if err != nil {
		return nil, errors.Trace(err)
	} else if err := client.Authenticate(); err != nil {
		return nil, errors.Trace(err)
	}

	endpointUrl, err := getVolumeEndpointURL(client, ecfg.region())
	if err != nil {
		if errors.IsNotFound(err) {
			return nil, errors.NewNotSupported(err, "volumes not supported")
		}
		return nil, errors.Annotate(err, "getting volume endpoint")
	}

	return &openstackStorageAdapter{
		cinderClient{cinder.Basic(endpointUrl, client.TenantId(), client.Token)},
		novaClient{nova.New(client)},
	}, nil
}
Esempio n. 2
0
func newOpenstackStorageAdapter(environConfig *config.Config) (openstackStorage, error) {
	ecfg, err := providerInstance.newConfig(environConfig)
	if err != nil {
		return nil, errors.Trace(err)
	}
	authClient := authClient(ecfg)
	if err := authClient.Authenticate(); err != nil {
		return nil, errors.Trace(err)
	}

	endpoint := authClient.EndpointsForRegion(ecfg.region())["volume"]
	endpointUrl, err := url.Parse(endpoint)
	if err != nil {
		return nil, errors.Annotate(err, "error parsing endpoint")
	}

	return &openstackStorageAdapter{
		cinderClient{cinder.Basic(endpointUrl, authClient.TenantId(), authClient.Token)},
		novaClient{nova.New(authClient)},
	}, nil
}
Esempio n. 3
0
File: cinder.go Progetto: bac/juju
	defer env.ecfgMutex.Unlock()

	if env.volumeURL == nil {
		url, err := getVolumeEndpointURL(env.client, env.cloud.Region)
		if errors.IsNotFound(err) {
			// No volume endpoint found; Cinder is not supported.
			return nil, errors.NotSupportedf("volumes")
		} else if err != nil {
			return nil, errors.Trace(err)
		}
		env.volumeURL = url
		logger.Debugf("volume URL: %v", url)
	}

	return &openstackStorageAdapter{
		cinderClient{cinder.Basic(env.volumeURL, env.client.TenantId(), env.client.Token)},
		novaClient{env.novaUnlocked},
	}, nil
}

type cinderProvider struct {
	storageAdapter OpenstackStorage
	envName        string
	modelUUID      string
	namespace      instance.Namespace
}

var _ storage.Provider = (*cinderProvider)(nil)

var cinderAttempt = utils.AttemptStrategy{
	Total: 1 * time.Minute,
Esempio n. 4
0
	return &cinderProvider{storageAdapter, envName, modelUUID}, nil
}

var newOpenstackStorage = func(env *Environ) (OpenstackStorage, error) {
	env.ecfgMutex.Lock()
	endpointUrl := env.volumeURL
	authClient := env.client
	envNovaClient := env.novaUnlocked
	env.ecfgMutex.Unlock()

	if endpointUrl == nil {
		return nil, errors.NotSupportedf("volumes")
	}

	return &openstackStorageAdapter{
		cinderClient{cinder.Basic(endpointUrl, authClient.TenantId(), authClient.Token)},
		novaClient{envNovaClient},
	}, nil
}

type cinderProvider struct {
	storageAdapter OpenstackStorage
	envName        string
	modelUUID      string
}

var _ storage.Provider = (*cinderProvider)(nil)

var cinderAttempt = utils.AttemptStrategy{
	Total: 1 * time.Minute,
	Delay: 5 * time.Second,