node.jsopenstackpkgcloud

Authenticate Username and Password in OpenStack with pkgcloud


I'm trying to call an API for password authentication in OpenStack. This is API that I curl and get the access token: Password authentication with unscoped authorization

I want to do the same thing in NodeJS and I'm a little confused. Can I do it cause I'm thinking maybe the problem is that it is not possible to do it like this; however this is the code that I've been trying:

var pkgcloud = require('pkgcloud');

var client = pkgcloud.compute.createClient({
    provider: 'openstack',
    username: <username>,
    password: <password>,
    authUrl: 'http://<ip>:<port>/',
    basePath: 'v3'
});
  client.getFlavors(function (err, flavors) {
    console.log("Error", err)
    console.log("Flavors", flavors)
})

client.getServers(function (err, servers) {
    console.log("Error", err)
    console.log("Servers", servers)
})

The getFlavors and getServers functions return 405 Method Not Allowed - The method is not allowed for the requested URL.

what is wrong with my code? and if I have to use another URL for getFlavors or any other function, where should I put it?


Solution

  • I did what Iarsks has said and also added a tenant id and it worked fine.

    This is the config that I used:

    var config = {
        provider: 'openstack',
        keystoneAuthVersion: 'v3',
        authUrl: '...',
        domainId: 'default',
        username: <username>,
        password: <password>,
        region: <region name which is provided in the cloud.yaml file in OpenStack>,
        tenantId: <the same as the Project ID>
    }