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 }
func (e *Environ) SetConfig(cfg *config.Config) error { ecfg, err := providerInstance.newConfig(cfg) if err != nil { return err } // At this point, the authentication method config value has been validated so we extract it's value here // to avoid having to validate again each time when creating the OpenStack client. e.ecfgMutex.Lock() defer e.ecfgMutex.Unlock() e.ecfgUnlocked = ecfg e.client = authClient(ecfg) e.novaUnlocked = nova.New(e.client) return nil }
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 }