Skip to content

Commit

Permalink
Merge pull request #21 from HapLifeMan/master
Browse files Browse the repository at this point in the history
Add region in KeystoneV3Authenticator credentials
  • Loading branch information
stefanodefaria authored Oct 26, 2021
2 parents 8be1e44 + 7033238 commit 1c91e9f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions KeystoneV3Authenticator.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class KeystoneV3Authenticator extends EventEmitter {
this.currentToken = null;
}

tryFindEndpointUrl(catalog, service, iface) {
tryFindEndpointUrl(catalog, service, iface, regionId) {
if (typeof iface === 'undefined') {
iface = "public";
}
Expand All @@ -21,7 +21,7 @@ class KeystoneV3Authenticator extends EventEmitter {
return null;
}

const endpoint = catalogEntry.endpoints.find(x => x.interface === iface);
const endpoint = catalogEntry.endpoints.find(x => x.interface === iface && (regionId ? x.region_id == regionId : true));
if (!endpoint) {
return null;
}
Expand Down Expand Up @@ -71,8 +71,8 @@ class KeystoneV3Authenticator extends EventEmitter {

const catalog = response.body.token.catalog;
const swiftUrl =
this.tryFindEndpointUrl(catalog, 'swift', credentials.endpointUrlInterface)
|| this.tryFindEndpointUrl(catalog, 'radosgw-swift', credentials.endpointUrlInterface); // many OpenStack clouds use ceph radosgw to provide swift
this.tryFindEndpointUrl(catalog, 'swift', credentials.endpointUrlInterface, credentials.regionId)
|| this.tryFindEndpointUrl(catalog, 'radosgw-swift', credentials.endpointUrlInterface, credentials.regionId); // many OpenStack clouds use ceph radosgw to provide swift

if (!swiftUrl) {
throw new Error('could not find swift or radosgw-swift service in catalog');
Expand All @@ -84,7 +84,7 @@ class KeystoneV3Authenticator extends EventEmitter {
swiftUrl: swiftUrl
}
};

async authenticate() {
if (!this.currentToken) {
this.currentToken = await this.getToken();
Expand All @@ -101,4 +101,4 @@ class KeystoneV3Authenticator extends EventEmitter {
}
}

module.exports = KeystoneV3Authenticator;
module.exports = KeystoneV3Authenticator;
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ let credentials = {
"password": "pasword",
"domainId": "e6efe92d05c2430ea7eb6f626815d0d8",
"projectId": "ff912d95d2eb46099e755cd268714d37",
"endpointUrlInterface": "public" // admin, internal or public. Value default: public
"endpointUrlInterface": "public", // admin, internal or public. Value default: public
"regionId": "GRA", // Optional
}

let client = new SwiftClient(new SwiftClient.KeystoneV3Authenticator(credentials));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openstack-swift-client",
"version": "2.2.0",
"version": "2.3.0",
"description": "Connects to OpenStack Swift storage servers",
"main": "index.js",
"types": "index.d.ts",
Expand Down

0 comments on commit 1c91e9f

Please sign in to comment.