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. var authModeCfg AuthMode e.ecfgMutex.Lock() defer e.ecfgMutex.Unlock() authModeCfg = AuthMode(ecfg.authMode()) e.ecfgUnlocked = ecfg e.client = e.authClient(ecfg, authModeCfg) e.novaUnlocked = nova.New(e.client) // create new control storage instance, existing instances continue // to reference their existing configuration. // public storage instance creation is deferred until needed since authenticated // access to the identity service is required so that any juju-tools endpoint can be used. e.storageUnlocked = &storage{ containerName: ecfg.controlBucket(), // this is possibly just a hack - if the ACL is swift.Private, // the machine won't be able to get the tools (401 error) containerACL: swift.PublicRead, swift: swift.New(e.client)} e.publicStorageUnlocked = nil return 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. var authMethodCfg AuthMethod e.ecfgMutex.Lock() defer e.ecfgMutex.Unlock() e.name = ecfg.Name() authMethodCfg = AuthMethod(ecfg.authMethod()) e.ecfgUnlocked = ecfg novaClient := e.client(ecfg, authMethodCfg) e.novaUnlocked = nova.New(novaClient) // create new storage instances, existing instances continue // to reference their existing configuration. e.storageUnlocked = &storage{ containerName: ecfg.controlBucket(), containerACL: swift.Private, swift: swift.New(e.client(ecfg, authMethodCfg))} if ecfg.publicBucket() != "" && ecfg.publicBucketURL() != "" { e.publicStorageUnlocked = &storage{ containerName: ecfg.publicBucket(), containerACL: swift.PublicRead, swift: swift.New(e.publicClient(ecfg))} } else { e.publicStorageUnlocked = nil } return nil }