Over a million developers have joined DZone.

Connecting to OpenStack in Node.js with pkgcloud

DZone's Guide to

Connecting to OpenStack in Node.js with pkgcloud

· Cloud Zone
Free Resource

Learn how our document data model can map directly to how you program your app, and native database features like secondary indexes, geospatial and text search give you full access to your data. Brought to you in partnership with MongoDB.

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.

Discover when your data grows or your application performance demands increase, MongoDB Atlas allows you to scale out your deployment with an automated sharding process that ensures zero application downtime. Brought to you in partnership with MongoDB.


Published at DZone with permission of Matt Farina, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


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

{{ parent.tldr }}

{{ parent.urlSource.name }}