npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pb-builder

v1.1.8

Published

node.js profitbricks vm builder and wrapper around the pb soap api

Downloads

15

Readme

profitbricks-builder

Description

node.js builder and wrapper for the profitbricks soap api

Motivation

The process of creating Virtual machines with the Profitbricks Soap Api requires a lot of Soap Api Calls. Every "Item" like DataCenter, Server, Storage, NIC, Server Storage Connection is created by a single soap call. For some Items it is even required to wait until the Datacenter is provisioned, before the next item can be created.

Since node http calls are always asynchronous, a good way to make a series of soap calls is to use a Promises/A+ library. The profitbricks-builder is using the petkaantonov/bluebird Promise library and is returning a thenable Promise for most calls.

This Frameworks wraps all soap api calls into a promise that can be queued by using .then

Usage

how to create the builder instance

PBBuilder = require('pb-builder')
pbBuilder = new PBBuilder()
promise = pbBuilder.initAsync(pb_wsdl_uri, pb_user, pb_pwd)

example to get detailed information on a dataCenter by dataCenterName

pbBuilder
    .initAsync(credentials.pb_url, credentials.pb_user, credentials.pb_pwd)
    .then ->
        return pbBuilder.getAllDataCentersAsync()
    .then (allDataCenters) ->
        dataCenter = pbContext.firstItem(
            pbContext.filter(allDataCenters, {dataCenterName: "myDataCenterName"}))
        return pbBuilder.getDataCenterDetailsAsync(dataCenter)
    .then (dataCenterDetails) ->
        debug(JSON.stringify(dataCenterDetails))
    .catch (e) ->
        console.log "pbBuilder chain failed '#{e}'"
        console.log e.stack

check the examples for more information.

The Profitbricks builder implementation has node style function only and is promisified with the bluebird lib. For that reason the promisified methods have an Async at the end of the method names.

running tests and samples

to not forget to run "npm install" once after checkout

run mocha tests:

./node_modules/.bin/mocha  -R tap --compilers coffee:coffee-script test/soapclient-test.coffee
./node_modules/.bin/mocha  -R tap --compilers coffee:coffee-script test/profitbricks_jobbuilder-test.coffee

# or just run
./node_modules/.bin/cake test

run samples:

# first provide your profitbricks credentials

# copy the credentials template file to credentials.json in your current working directory
cp credentials_tmpl.json credentials.json
#  and config with your profitbricks user and passsword

# after that run a sample like this:
DEBUG=* ./node_modules/.bin/coffee examples/create_datacenter.coffee

simple repl tool

# in the examples dir there is a very simple repl (read eval print loop) command line tool, start it with

./bin/pb_cli

# see "run samples" section how to set up your credentials

# cmd can be any profitbricks soap api method, args are passed as JSON string, p.e.

pb_cli:command: getAllDataCenters

pb_cli:command: getDataCenter {"dataCenterId": "0e381ab3-133b-49d3-b5fa-6382c7add1a4"}

# there is a help command, that list soapMethod and there input. Help data is from wsdl description

pb_cli:command: help
# list all soap methods

pb_cli:command: help snapshot
# list all soap methods containing the word snapshot

pb_cli:command: help getDataCenter
# shows the input description for the soap method

development

development is taking place in the coffee files in the src folder. the javascript files are generated into the lib directory with the command:

./node_modules/.bin/cake build