added support for gophercloud's PopulateApi

This commit is contained in:
Torrent Glenn 2014-02-04 12:27:24 -08:00 committed by Ben Broderick Phillips
parent 44f5f059e6
commit ee95fbbd99
2 changed files with 14 additions and 11 deletions

View File

@ -60,13 +60,15 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
if err != nil { if err != nil {
return nil, err return nil, err
} }
api := &gophercloud.ApiCriteria{ //fetches the api requisites from gophercloud for the appropriate
Name: "cloudServersOpenStack", //openstack variant
Region: b.config.AccessConfig.Region(), api, err := gophercloud.PopulateApi(b.config.RunConfig.OpenstackProvider)
VersionId: "2", if err != nil {
UrlChoice: gophercloud.PublicURL, return nil, err
} }
csp, err := gophercloud.ServersApi(auth, *api) api.Region = b.config.AccessConfig.Region()
csp, err := gophercloud.ServersApi(auth, api)
if err != nil { if err != nil {
log.Printf("Region: %s", b.config.AccessConfig.Region()) log.Printf("Region: %s", b.config.AccessConfig.Region())
return nil, err return nil, err

View File

@ -10,11 +10,12 @@ import (
// RunConfig contains configuration for running an instance from a source // RunConfig contains configuration for running an instance from a source
// image and details on how to access that launched image. // image and details on how to access that launched image.
type RunConfig struct { type RunConfig struct {
SourceImage string `mapstructure:"source_image"` SourceImage string `mapstructure:"source_image"`
Flavor string `mapstructure:"flavor"` Flavor string `mapstructure:"flavor"`
RawSSHTimeout string `mapstructure:"ssh_timeout"` RawSSHTimeout string `mapstructure:"ssh_timeout"`
SSHUsername string `mapstructure:"ssh_username"` SSHUsername string `mapstructure:"ssh_username"`
SSHPort int `mapstructure:"ssh_port"` SSHPort int `mapstructure:"ssh_port"`
OpenstackProvider string `mapstructure:"openstack_provider"`
// Unexported fields that are calculated from others // Unexported fields that are calculated from others
sshTimeout time.Duration sshTimeout time.Duration