From ee95fbbd99d1ccbc4cbf847e610760dd0b3737f3 Mon Sep 17 00:00:00 2001 From: Torrent Glenn Date: Tue, 4 Feb 2014 12:27:24 -0800 Subject: [PATCH] added support for gophercloud's PopulateApi --- builder/openstack/builder.go | 14 ++++++++------ builder/openstack/run_config.go | 11 ++++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index ff123f6f3..d63e847f2 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -60,13 +60,15 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe if err != nil { return nil, err } - api := &gophercloud.ApiCriteria{ - Name: "cloudServersOpenStack", - Region: b.config.AccessConfig.Region(), - VersionId: "2", - UrlChoice: gophercloud.PublicURL, + //fetches the api requisites from gophercloud for the appropriate + //openstack variant + api, err := gophercloud.PopulateApi(b.config.RunConfig.OpenstackProvider) + if err != nil { + return nil, err } - csp, err := gophercloud.ServersApi(auth, *api) + api.Region = b.config.AccessConfig.Region() + + csp, err := gophercloud.ServersApi(auth, api) if err != nil { log.Printf("Region: %s", b.config.AccessConfig.Region()) return nil, err diff --git a/builder/openstack/run_config.go b/builder/openstack/run_config.go index 6618472db..688d681a5 100644 --- a/builder/openstack/run_config.go +++ b/builder/openstack/run_config.go @@ -10,11 +10,12 @@ import ( // RunConfig contains configuration for running an instance from a source // image and details on how to access that launched image. type RunConfig struct { - SourceImage string `mapstructure:"source_image"` - Flavor string `mapstructure:"flavor"` - RawSSHTimeout string `mapstructure:"ssh_timeout"` - SSHUsername string `mapstructure:"ssh_username"` - SSHPort int `mapstructure:"ssh_port"` + SourceImage string `mapstructure:"source_image"` + Flavor string `mapstructure:"flavor"` + RawSSHTimeout string `mapstructure:"ssh_timeout"` + SSHUsername string `mapstructure:"ssh_username"` + SSHPort int `mapstructure:"ssh_port"` + OpenstackProvider string `mapstructure:"openstack_provider"` // Unexported fields that are calculated from others sshTimeout time.Duration