Eye on Blades Blog: Trends in Infrastructure
Get HP BladeSystem news, upcoming event information, technology trends, and product information to stay up to date with what is happening in the world of blades.

Integrating BladeSystem Matrix into a Chargeback or Billing system

I got a call last week enquiring how the IaaS APIs of BladeSystem Matrix (Matrix) could be used to integrate with a chargeback or billing system at a customer site. its a snowy day in Boulder and being a fair weather skier I thought I would spend a few moments and put together some examples of how you could do this.


How Matrix calculates a service cost


Matrix service templates are listed in the template catalog, which shows their name, a description of the service template, and an associated service cost. This cost is calculated by adding the individual costs of each of the service elements in the template together. For example, in a service template the service designer specifies costs for each class of server, for each GB of a class of storage, and for each IP address consumed on a class of subnet. The cost of the service is calculated by combining these unit costs with the amount of each type of resource consumed to create a total. The template catalog shows the cost to deploy the template. However, once the service is deployed, the user can choose to add additional storage, or perhaps choose to temporarily release (suspend) a server. When the user adds additional storage, their service cost will increase based on the template unit cost per GB of storage. Similarly when the user chooses to temporarily suspend a server, their service costs reduces, reflecting that they have reduced their resource consumption. I'm showing an example of the cost breakout chart in the Matrix template designer tool.



Linking to a charge back or billing system


The ListServices web service call can be used by an administrative user to return summary information about the services deployed in Matrix. The Web service return includes information on the current resource consumption cost of that service. Let's assume the IaaS provider wants to chargeback to their customers based on a 15 minute usage increment. They could use a single CRON job on their billing system to fetch usage information every 15 minutes, as shown in figure 2 below.



The content of the CRON job is shown in figure 3. Matrix 6.0 includes a handy CLI wrapper which I am going use in this example. The wrapper is written in Java, so I can run it on any machine and use the underlying web services to connect the Matrix environment. In my example I copied the ioexec.jar file from the Program Files/HP/Insight Orchestration/cli directory to my linux machine. You could also use your favorite wsdl2{java,perl,python,c,.net} tool or the wsdl import feature in Operations Orchestration to create something similar.


Here is my outline of the bash script:


 # sample charge back cron job
# Cron runs script every 15 minutes
#
###################################################################
# charge_owner: used to apply incremental charge to owner's account
# Inputs: service_name owner cost cost_units
# Returns: !=0 if owner has no more credit
function charge_owner
{
echo service $1 owner "$2" cost $3 $4
# insert commands to charge customer here!
return 0
}
###################################################################
# credit_denied: called when owner has no more credit on service
# Inputs: service_name owner
function credit_denied
{
echo suspend service $1 of owner $2
# Insert commands to handle over drawn customers here
# ioexec deactive service -s "$1" -c chargeback.conf
return 0
}


####################################################################
# process_chargeback
# Inputs: processes listServices output invoking charge_owner &
#         credit_denied to perform chargeback processing
function process_chargeback
{
while read -r LINE
do
    FIELD=${LINE#*services*.}
    FIELD=${FIELD%%=*}
    ARG="${LINE#*=}"
  
    case "$FIELD"
    in
         name)  service="$ARG";;
         cost.value)    cost="$ARG";;
         cost.units)    units="$ARG";;
         ownerName)     owner="$ARG";
                        charge_owner "$service" "$owner" "$cost" "$units"
                        if
                        then
                            credit_denied "$service" "$owner"  
                        fi;;
    esac
    :
done


}


ioexec list services -o raw -c chargeback.conf | process_chargeback


The script uses the ioexec wrapper to invoke the list Services web service call. I then pipe the results to process_chargeback  to parse the results extracting the service name, current charge rate and charge units, and service owner. The information is passed to the chargeback system via two functions charge_owner and credit_denied. The sample code has a stubbed version of charge_owner, which takes the service name, charge rate, charge units and owner arguments and simply echos them. This routine could be extended to insert the usage information into a database or pass it directly to a charge back system. If the routine returns a non-zero result (indicating an error), then the credit_denied routine is called. This is another stub which, for now, just echos the name of owner and the associated service. This could be extended, as shown, to do other operations - such as invoke the deactivateService web service call to shut down the service when the user has no more credit.


More Complex Scenarios


The example I've given is very simple, but hopefully is enough to get people started on their own integrations. Matrix has additional integration points that can trigger workflows to perform additional actions. An example of one of these triggers is the "Approval" workflow that is used to gate requests for new resource allocation in Matrix. This trigger point could be used to do a credit check on a customer prior to proceeding with a resource deployment operation.


I'd love feedback about the charge back or billing tools people use today, and what kind of out-of-the-box integrations would be most useful.

Comments
Anonymous(anon) | ‎04-01-2010 10:29 AM

Hi Nigel,

Can you tell me if this works only when a service is created through OO/IO?  Also, does it meter use (CPU, Storage, Badnwidth), or just show that the service is currently in place and “live”?

nigel.cook | ‎04-01-2010 11:46 PM

Hi Rod,


You are correct.. The Matrix APIs will only report chargeback information on services that have been created either through the Matrix Self service portal, or via the web service APIs. It wont report on other services in the infrastructure created through other means.


The chargeback model lets the Matrix service operator set the charges for components in the service. The charge back query returns an aggregate cost for charges assocated with



  1. (virtual) server instances (for example you might set a charge on a particular configuration blade server at $10/hr  or for a medium configuration of VM for $0.12 per hour),

  2. amount of storage (for example you could decide to charge RAID5 storage at $2 per GB per month, and VMFS storage at $1 per GB per month), and

  3. IP addresses (for example you set  $5/month for a public IP address and $0.10 for a private IP address).


We currently dont have metering for the number of disk I/O operations or amount of traffic in and out of the environment, although a provider could install specific agents into the environment to additionally account for this.

Anonymous(anon) | ‎04-06-2010 03:39 PM

Hi

I was wondering if it might not be better to add a OO job to each of the relevant hooks in the template - like service start, flex, modifiction and send out a email to an accounting account, that could then charge based on the audit trail provided by this.

This would give you a passive way of collecting information, instead of actively polling

AlexSamad | ‎04-06-2010 03:56 PM

Hi Nigel

I was wondering if it would be better to grab audit information and do passive gathering of information from matrix, attached OO workflows, to the relevant hooks - start service, flex service, stop service and send an email to a audit email address that can gather the information and produce charge back info from there.

You only worry then is to make sure you have a working email system.

Alex

nigel.cook | ‎04-07-2010 02:04 AM

Alex you ask a good question..

You could use the workflows to simply do a charge on submission. You would then also need to worry about incremental charges as the customer add/removed servers, terminated the lease early, and so on. You also have an issue of some one who creates a service with no end date.. you need to figure out how much you charge them.

The polling scheme eliminates that complexity at the expense of hitting the system more frequently. I notice amazon does an hourly billing.

One alternative might be to mix the schemes – so use the workflows to write an initial “service start” record (so you guarantee you always bill them minimum 1hr and also have an trail of service add/changes/deletes in the bill), and then poll every 60 minutes for the actual usage charge data. This reduces the load on the system, but provides the ability to get the revenue for very short lived services.

A good workflow hook to take a look at is the global end action.

Regards

Nigel

Anonymous(anon) | ‎05-08-2010 02:12 AM

Secured process transactions solution will overcome the multi-currency barrier and prevent chargeback risks by making customers feel as if they are shopping in their own country and in their own currency.

Leave a Comment

We encourage you to share your comments on this post. Comments are moderated and will be reviewed
and posted as promptly as possible during regular business hours

To ensure your comment is published, be sure to follow the community guidelines.

Be sure to enter a unique name. You can't reuse a name that's already in use.
Be sure to enter a unique email address. You can't reuse an email address that's already in use.
Type the characters you see in the picture above.Type the words you hear.
Search
Showing results for 
Search instead for 
Do you mean 
About the Author


Follow Us
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.