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

hpcsa

v3.0.0

Published

hp csa client library

Downloads

11

Readme

#hpcsa.js

hpcsa.js is a nodejs library for automating Hewlett Packard's Cloud Service Automation product. You can use it to build testing tools and alternative front end interfaces to your cloud services.

This library uses promises. When you invoke any of the provided methods, a promise will be returned. If you're new to promises, read this and then come back.

##Install In a new, empty folder, run

> npm install hpcsa

and in your script, require the module:

var hpcsa = require ('hpcsa');

##Usage First you need to log in to your CSA instance.

var hpcsa = require ('hpcsa');

var login = hpcsa.login("https://myCsaServer:8444", // your HP CSA server 
			"consumer",                 // marketplace username
			"cloud"                     // marketplace password
			"CSA_CONSUMER",             // CSA organisation name
			"idmTransportUser",         // idm username
			"idmTransportUser",         // idm password
			true                        // false to turn off certificate checking
)

login.then(function(xAuthToken){
	console.log ("congratulations. your token is " + xAuthToken)
})

Once you've verified this works, you can move onto actually doing stuff.

###Order a subscription Here's how to order a basic subscription (add this to the bottom of the above code):


login.then(function(){
	return hpcsa.order(
		"Global Shared Catalog", // catalog name
		"SIMPLE_SYSTEM",         // offering category name
		"RHEL7 Virtual Server",  // offering name
		{},                      // subscriber options
		"My redhat server",      // subscription name
	) 
})

I've left the subscriber options empty for the moment; if your service offering has default values for all the options, then you can go ahead and run the above to create a new subscription.

If you want to specify options, then just provide an object to the order method, like so:

login.then(function(){
	return hpcsa.order(
		"Global Shared Catalog", 
		"SIMPLE_SYSTEM",
		"RHEL7 Virtual Server", 
		{
			"PROJECTCODE": "P101010"
			"Compute Class": "Gargantuan"
		},
		"My redhat server"

	)  

})

In the subscriber options object you can specify either an option set display name. or a property name. The below screenshot shows both types. In the design shown, Compute Class is an option set, and PROJECTCODE is the real name of the Project Code property.

csa screenshot

you can grab the option models (including default values) by running the following:

login
.then(function(){
	return hpcsa.getOptionModels("CSA")
})
.then(function(offeringsWithOptions){
	console.log (prettyjson.render(offeringsWithOptions))
})

// -> 
//- 
//  offeringName: CSATesterOffering
//  offeringId:   2c9030e44f3fd64b014f4173135727e5
//  category:     SIMPLE_SYSTEM
//  catalogId:    90d9650a36988e5d0136988f03ab000f
//  optionModel: 
//    - 
//      Small: true
//    - 
//      Medium: false
//    - 
//      Gargantuan: false
//    - 
//      PROJECTCODE: P012345
//    - 
//      SUPPORTTEAM: OPS
//- 
//  offeringName: CSATestercles
//  offeringId:   2c9030e44fdfb913014ff442cbd90006
//  category:     SIMPLE_SYSTEM
//  catalogId:    90d9650a36988e5d0136988f03ab000f
//  optionModel: 
//    - 
//      Small: true
//    - 
//      Medium: false
//    - 
//      Gargantuan: false
//    - 
//      PROJECTCODE: P012345
//    - 
//      SUPPORTTEAM: OPS
 

###Modify a subscription

login.then(function(){
	return hpcsa.modify	(
		"90d9650a36988e5d0136988f03ab000f", // catalog ID
		"SIMPLE_SYSTEM",                    // category name
		"My redhat server"                  // your sub name or ID
		{"Compute Class": "Small"},         // new options

    ) 
})

###Run a control action

login.then(function(){
	hpcsa.control (	
		"90d9650a36988e5d0136988f03ab000f", // catalog ID
		"SIMPLE_SYSTEM",                    // category name
		"My redhat server",                 // your sub name or ID
		"Server",                           // component name
		"Reboot Server"                     // control action name
	)
})

###Cancel a subscription

login.then(function(){
	return hpcsa.cancel (	
		"90d9650a36988e5d0136988f03ab000f", // catalog ID
		"SIMPLE_SYSTEM",                    // category name
		"My redhat server",                 // your sub name or ID
	)
})

##Putting it all together Using promises allows us to easily chain and recombine asynchronous actions. Here's how you would order a new subscription, immediately modify it, and then finally cancel it:

login
.then(function(){
	return hpcsa.order(
		"Global Shared Catalog",
		"SIMPLE_SYSTEM", 
		"RHEL7 Virtual Server",
		{},
		"My redhat server"
	)
).then(function(){
	return hpcsa.modify	(
		"90d9650a36988e5d0136988f03ab000f",
		"SIMPLE_SYSTEM",
		{"Compute Class": "Small"},
		"My redhat server",
    ) 
).then(function(){
	return hpcsa.cancel (	
		"90d9650a36988e5d0136988f03ab000f",
		"SIMPLE_SYSTEM",
		"My redhat server",
	)
})

Here's how you would create three subscriptions simultaneously!


var newSubs = [
	[
		"Global Shared Catalog",
		"SIMPLE_SYSTEM", 
		"Windows 2008 R2 SQL server",
		{"COLLATION":"Latin"}
		"My SQL server",
	],
	[
		"Global Shared Catalog",
		"SIMPLE_SYSTEM", 
		"RHEL7 Virtual Server",
		{}
		"My app server",
	],
	[
		"Global Shared Catalog",
		"SIMPLE_SYSTEM", 
		"RHEL7 Virtual Server",
		{"Install Apache": true}
		"My web server",
    ]
]

login.then(function(){
	//convert each array element to a promise
	var promises = newSubs.map(function(sub){
		return hpcsa.order.apply(this, sub)
	})

	// return when they're all done!
	return Promise.all(promises)
})