From b6a6c8571b27bd4b935b090af36cc707f7687e81 Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Sat, 31 Aug 2013 21:58:52 -0700 Subject: [PATCH 1/2] Allow the Openstack project to be specified It isn't actually optional, according to the spec --- builder/openstack/access_config.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builder/openstack/access_config.go b/builder/openstack/access_config.go index 489e43bea..9805b6480 100644 --- a/builder/openstack/access_config.go +++ b/builder/openstack/access_config.go @@ -11,6 +11,7 @@ import ( type AccessConfig struct { Username string `mapstructure:"username"` Password string `mapstructure:"password"` + Project string `mapstructure:"project"` Provider string `mapstructure:"provider"` RawRegion string `mapstructure:"region"` } @@ -20,6 +21,7 @@ type AccessConfig struct { func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) { username := c.Username password := c.Password + project := c.Project provider := c.Provider if username == "" { @@ -28,6 +30,9 @@ func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) { if password == "" { password = os.Getenv("SDK_PASSWORD") } + if project == "" { + project = os.Getenv("SDK_PROJECT") + } if provider == "" { provider = os.Getenv("SDK_PROVIDER") } @@ -35,6 +40,7 @@ func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) { authoptions := gophercloud.AuthOptions{ Username: username, Password: password, + TenantName: project, AllowReauth: true, } From 47ee7ca9775a7dc40c6c42e261b3207cd27b6f01 Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Mon, 2 Sep 2013 10:22:14 -0700 Subject: [PATCH 2/2] Only pass the project if it is specified --- builder/openstack/access_config.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/builder/openstack/access_config.go b/builder/openstack/access_config.go index 9805b6480..82fcee185 100644 --- a/builder/openstack/access_config.go +++ b/builder/openstack/access_config.go @@ -40,10 +40,13 @@ func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) { authoptions := gophercloud.AuthOptions{ Username: username, Password: password, - TenantName: project, AllowReauth: true, } + if project != "" { + authoptions.TenantName = project + } + return gophercloud.Authenticate(provider, authoptions) }