Skip to content

Commit

Permalink
openstack provider credentials should consider project domain id
Browse files Browse the repository at this point in the history
juju autoload-credentials ignores the OS_PROJECT_DOMAIN_ID if set
and looks for only OS_PROJECT_DOMAIN_NAME. However there are cases
where openrc downloaded from OpenStack Dashboard for non-admin user
sets only OS_PROJECT_DOMAIN_ID. In these cases juju bootstrap fails
with authentication error since juju is not aware of project domain
id and project domain name is empty.
This change reads OS_PROJECT_DOMAIN_ID and sets in CredentialsAttribute
map. The same have been passed to the client for authentication
purpose.

- This PR depends on PR submitted for go-goose package
  go-goose/goose#89

https://bugs.launchpad.net/juju/+bug/1772649
  • Loading branch information
hemanthnakkina committed Mar 31, 2021
1 parent 70d9cfc commit 1f06eef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions provider/openstack/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
CredAttrPassword = "password"
CredAttrDomainName = "domain-name"
CredAttrProjectDomainName = "project-domain-name"
CredAttrProjectDomainID = "project-domain-id"
CredAttrUserDomainName = "user-domain-name"
CredAttrAccessKey = "access-key"
CredAttrSecretKey = "secret-key"
Expand Down Expand Up @@ -70,6 +71,11 @@ func (OpenstackCredentials) CredentialSchemas() map[cloud.AuthType]cloud.Credent
Description: "The OpenStack project domain name.",
Optional: true,
},
}, {
CredAttrProjectDomainID, cloud.CredentialAttr{
Description: "The OpenStack project domain ID.",
Optional: true,
},
}, {
CredAttrUserDomainName, cloud.CredentialAttr{
Description: "The OpenStack user domain name.",
Expand Down Expand Up @@ -185,6 +191,7 @@ func (c OpenstackCredentials) detectCredential() (*cloud.Credential, string, str
CredAttrTenantID: creds.TenantID,
CredAttrUserDomainName: creds.UserDomain,
CredAttrProjectDomainName: creds.ProjectDomain,
CredAttrProjectDomainID: creds.ProjectDomainID,
CredAttrDomainName: creds.Domain,
CredAttrVersion: version,
},
Expand Down
1 change: 1 addition & 0 deletions provider/openstack/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ func newCredentials(spec environscloudspec.CloudSpec) (identity.Credentials, ide
cred.User = credAttrs[CredAttrUserName]
cred.Secrets = credAttrs[CredAttrPassword]
cred.ProjectDomain = credAttrs[CredAttrProjectDomainName]
cred.ProjectDomainID = credAttrs[CredAttrProjectDomainID]
cred.UserDomain = credAttrs[CredAttrUserDomainName]
cred.Domain = credAttrs[CredAttrDomainName]
if credAttrs[CredAttrVersion] != "" {
Expand Down

0 comments on commit 1f06eef

Please sign in to comment.