コード例 #1
0
ファイル: cinder.go プロジェクト: xushiwei/juju
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
}
コード例 #2
0
ファイル: cinder.go プロジェクト: Pankov404/juju
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
}
コード例 #3
0
ファイル: cinder.go プロジェクト: 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,
コード例 #4
0
ファイル: cinder.go プロジェクト: kat-co/juju
	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,