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

Site24x7 - Full stack It Infrastructure Monitoring from the cloud. Sign up for free trial.

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.

Site24x7 - Full stack It Infrastructure Monitoring from the cloud. Sign up for free trial.

Topics:

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

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

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.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}