Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Connecting to OpenStack in Node.js with pkgcloud

DZone's Guide to

Connecting to OpenStack in Node.js with pkgcloud

· Cloud Zone ·
Free Resource

Insight into the right steps to take for migrating workloads to public cloud and successfully reducing cost as a result. Read the Guide.

If you've ever wanted to build a node.js app that worked with OpenStack, HP Helion OpenStack, or the HP Public Cloud the package to use pkgcloud. This is a multi-cloud library for node.js that includes support some of the common components of OpenStack. It's supported enough by the OpenStack community that it's the node.js library listed on the OpenStack developer portal.

Note, until recently there was the hpcloud-js library that I've now deprecated because it is superseded by pkgcloud. hpcloud-js served us well but given the support for OpenStackn in pkgcloud and the superior feature coverage we've decided to direct users there instead.

Creating A Client

Let's look at an example where we create an object storage client. This client can be used to manage objects, containers, meta-data, and more.

var client = require('pkgcloud').storage.createClient({
    provider: 'openstack',
    username: 'your-user-name',
    password: 'your-password',
    tenantId: 'exampleProject',
    region: 'exampleRegion',
    authUrl: 'https://identity.example.com/v2.0/'
});

If you're connecting to the HP Public Cloud and would like to use your keys instead of a username and password the hp provider can be used.

Retrieval Example

Given the client in the previous example, we can retrieve information from the endpoint. For example, we can get a list of containers like so.

client.getContainers(function(err, containers) {
    // Containers is an array of container objects.
})

Examples and Documentation

There's a bit of documentation and examples in the pkgcloud docs. If you're looking to dive in it's worth starting there.

TrueSight Cloud Cost Control provides visibility and control over multi-cloud costs including AWS, Azure, Google Cloud, and others.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}