diff --git a/pkg/mcclient/catalog.go b/pkg/mcclient/catalog.go index 965b003b26..4e38e1003a 100644 --- a/pkg/mcclient/catalog.go +++ b/pkg/mcclient/catalog.go @@ -18,4 +18,5 @@ type IServiceCatalog interface { Len() int GetServiceURL(service, region, zone, endpointType string) (string, error) GetServiceURLs(service, region, zone, endpointType string) ([]string, error) + GetServicesByInterface(region string, infType string) []ExternalService } diff --git a/pkg/mcclient/mcclient.go b/pkg/mcclient/mcclient.go index 6e0ff138d6..db1572e505 100644 --- a/pkg/mcclient/mcclient.go +++ b/pkg/mcclient/mcclient.go @@ -97,6 +97,10 @@ func (this *Client) SetServiceCatalog(catalog IServiceCatalog) { this.serviceCatalog = catalog } +func (this *Client) GetServiceCatalog() IServiceCatalog { + return this.serviceCatalog +} + func (this *Client) NewAuthTokenCredential() TokenCredential { if this.AuthVersion() == "v3" { return &TokenCredentialV3{} diff --git a/pkg/mcclient/token.go b/pkg/mcclient/token.go index 32d43d2f56..dd25edaafc 100644 --- a/pkg/mcclient/token.go +++ b/pkg/mcclient/token.go @@ -18,8 +18,9 @@ import ( "time" "yunion.io/x/jsonutils" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/pkg/gotypes" + + "yunion.io/x/onecloud/pkg/util/rbacutils" ) type ExternalService struct { diff --git a/pkg/mcclient/token2.go b/pkg/mcclient/token2.go index 4d9de1135b..1f8b05a25c 100644 --- a/pkg/mcclient/token2.go +++ b/pkg/mcclient/token2.go @@ -185,6 +185,10 @@ func (this *TokenCredentialV2) GetServiceURLs(service, region, zone, endpointTyp return this.ServiceCatalog.GetServiceURLs(service, region, zone, endpointType) } +func (this *TokenCredentialV2) GetServicesByInterface(region string, infType string) []ExternalService { + return nil +} + func (this *TokenCredentialV2) GetInternalServices(region string) []string { return nil } @@ -297,6 +301,10 @@ func (catalog KeystoneServiceCatalogV2) GetServiceURLs(service, region, zone, en return []string{url}, nil } +func (catalog KeystoneServiceCatalogV2) GetServicesByInterface(region string, infType string) []ExternalService { + return nil +} + func (ep KeystoneEndpointV2) getURL(epType string) string { switch epType { case "publicURL": diff --git a/pkg/mcclient/token3.go b/pkg/mcclient/token3.go index 8ab4f9eb78..784fe872f4 100644 --- a/pkg/mcclient/token3.go +++ b/pkg/mcclient/token3.go @@ -189,6 +189,10 @@ func (this *TokenCredentialV3) GetServiceURLs(service, region, zone, endpointTyp return this.Token.Catalog.GetServiceURLs(service, region, zone, endpointType) } +func (this *TokenCredentialV3) GetServicesByInterface(region string, infType string) []ExternalService { + return this.Token.Catalog.GetServicesByInterface(region, infType) +} + func (this *TokenCredentialV3) GetInternalServices(region string) []string { return this.Token.Catalog.getInternalServices(region) } @@ -232,11 +236,15 @@ func (catalog KeystoneServiceCatalogV3) getInternalServices(region string) []str } func (catalog KeystoneServiceCatalogV3) getExternalServices(region string) []ExternalService { + return catalog.GetServicesByInterface(region, "console") +} + +func (catalog KeystoneServiceCatalogV3) GetServicesByInterface(region string, infType string) []ExternalService { services := make([]ExternalService, 0) for i := 0; i < len(catalog); i++ { for j := 0; j < len(catalog[i].Endpoints); j++ { if catalog[i].Endpoints[j].RegionId == region && - catalog[i].Endpoints[j].Interface == "console" && + catalog[i].Endpoints[j].Interface == infType && len(catalog[i].Endpoints[j].Name) > 0 { srv := ExternalService{Name: catalog[i].Endpoints[j].Name, Url: catalog[i].Endpoints[j].Url} diff --git a/pkg/mcclient/tokensimple.go b/pkg/mcclient/tokensimple.go index c0c6bfe241..1ae26f6f87 100644 --- a/pkg/mcclient/tokensimple.go +++ b/pkg/mcclient/tokensimple.go @@ -149,6 +149,10 @@ func (self *SSimpleToken) GetServiceURLs(service, region, zone, endpointType str return nil, fmt.Errorf("Not available") } +func (this *SSimpleToken) GetServicesByInterface(region string, infType string) []ExternalService { + return nil +} + func (self *SSimpleToken) GetInternalServices(region string) []string { return nil }