28
28
"launchpad.net/juju-core/environs/imagemetadata"
29
29
"launchpad.net/juju-core/environs/instances"
30
30
"launchpad.net/juju-core/environs/simplestreams"
31
envtools "launchpad.net/juju-core/environs/tools"
31
32
"launchpad.net/juju-core/instance"
32
33
"launchpad.net/juju-core/names"
33
34
"launchpad.net/juju-core/provider"
229
230
novaUnlocked *nova.Client
230
231
storageUnlocked environs.Storage
231
232
publicStorageUnlocked environs.StorageReader // optional.
232
// An ordered list of paths in which to find the simplestreams index files used to
233
// An ordered list of sources in which to find the simplestreams index files used to
233
234
// look up image ids.
234
imageBaseURLs []string
235
imageSources []simplestreams.DataSource
235
236
// An ordered list of paths in which to find the simplestreams index files used to
236
237
// look up tools ids.
237
toolsBaseURLs []string
238
toolsSources []simplestreams.DataSource
240
241
var _ environs.Environ = (*environ)(nil)
241
var _ imagemetadata.SupportsCustomURLs = (*environ)(nil)
242
var _ imagemetadata.SupportsCustomSources = (*environ)(nil)
243
var _ envtools.SupportsCustomSources = (*environ)(nil)
242
244
var _ simplestreams.HasRegion = (*environ)(nil)
244
246
type openstackInstance struct {
551
// GetImageBaseURLs returns a list of URLs which are used to search for simplestreams image metadata.
552
func (e *environ) GetImageBaseURLs() ([]string, error) {
553
// GetImageSources returns a list of sources which are used to search for simplestreams image metadata.
554
func (e *environ) GetImageSources() ([]simplestreams.DataSource, error) {
553
555
e.imageBaseMutex.Lock()
554
556
defer e.imageBaseMutex.Unlock()
556
if e.imageBaseURLs != nil {
557
return e.imageBaseURLs, nil
558
if e.imageSources != nil {
559
return e.imageSources, nil
559
561
if !e.client.IsAuthenticated() {
560
562
err := e.client.Authenticate()
565
// Add the simplestreams base URL off the public bucket.
566
jujuImageURL, err := e.PublicStorage().URL("")
568
e.imageBaseURLs = append(e.imageBaseURLs, jujuImageURL)
567
// Add the simplestreams source off the control bucket.
568
e.imageSources = append(e.imageSources, environs.NewStorageSimpleStreamsDataSource(e.Storage(), ""))
569
// Add the simplestreams source off the public bucket.
570
e.imageSources = append(e.imageSources, environs.NewStorageSimpleStreamsDataSource(e.PublicStorage(), ""))
570
571
// Add the simplestreams base URL from keystone if it is defined.
571
572
productStreamsURL, err := e.client.MakeServiceURL("product-streams", nil)
573
574
// if !e.Config().SSLHostnameVerification() {
574
575
// productStreamsURL = "nonvalidating-" + productStreamsURL
576
e.imageBaseURLs = append(e.imageBaseURLs, productStreamsURL)
577
e.imageSources = append(e.imageSources, simplestreams.NewURLDataSource(productStreamsURL))
578
return e.imageBaseURLs, nil
579
return e.imageSources, nil
581
// GetToolsBaseURLs returns a list of URLs which are used to search for simplestreams tools metadata.
582
func (e *environ) GetToolsBaseURLs() ([]string, error) {
582
// GetToolsSources returns a list of sources which are used to search for simplestreams tools metadata.
583
func (e *environ) GetToolsSources() ([]simplestreams.DataSource, error) {
583
584
e.toolsBaseMutex.Lock()
584
585
defer e.toolsBaseMutex.Unlock()
586
if e.toolsBaseURLs != nil {
587
return e.toolsBaseURLs, nil
587
if e.toolsSources != nil {
588
return e.toolsSources, nil
589
590
if !e.client.IsAuthenticated() {
590
591
err := e.client.Authenticate()
596
// Add the simplestreams source off the control bucket.
597
e.toolsSources = append(e.toolsSources, environs.NewStorageSimpleStreamsDataSource(e.Storage(), environs.BaseToolsPath))
595
598
// Add the simplestreams base URL from keystone if it is defined.
596
599
toolsURL, err := e.client.MakeServiceURL("juju-tools", nil)
598
e.toolsBaseURLs = append(e.toolsBaseURLs, toolsURL)
601
e.toolsSources = append(e.toolsSources, simplestreams.NewURLDataSource(toolsURL))
600
return e.toolsBaseURLs, nil
603
return e.toolsSources, nil
603
606
// allocatePublicIP tries to find an available floating IP address, or