Monday, October 1, 2012

Cloud Foundry VMC-ng Has Helpful Client Logging

I noticed on the twittersphere that Brian McClain and Mark Lucovsky had a small exchange about the latest tips and tricks for developing Cloud Foundry API clients. Brian has written a Cloud Foundry Chaos Monkey. The important thing to note is the latest cfoundry gem maintained by Alex Suraci on the Cloud Foundry frameworks team has excellent client logging support of Cloud Controller calls. The cfoundry gem is simply a nice ruby wrapper around the Cloud Controller REST API. You can see these calls in action by using the latest pre-release version of vmc (which also is a gem), which we call vmc-ng where the ng is for next generation. The latest vmc builds upon the latest cfoundry gem.

A few things to note about using vmc-ng:
1) You should install it with gem install vmc --pre where the --pre gives you the ng bits. Note that this is preview code and not fully baked yet.
2) vmc-ng functionality is not enabled by default, you need to create a file or directory in your ~/.vmc directory called use-ng. If you do not have this, vmc will fall back to use the standard version without the new client logging capabilities
3) In order to switch back to the old vmc, simple remove the ~/.vmc/use-ng file or directory.
4) The syntax of some of the commands has changed, so make liberal use of the help. One of my favorites is the updated line view of applications vmc apps -l and you can see an example of that below. Another great switch is -t that turns on tracing and shows all of the HTTP request/response in standard out.
5) When using vmc-ng, the Cloud Controller HTTP calls are logged in the ~/.vmc/logs/api.cloudfoundry.com.log file, where api.cloudfoundry.com is the target.

Check out the gist for a full example using vmc-ng and illustrating the new client logging feature.