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.


9 comments:

jambay said...

Mark also provided a tweet snippet that shows how to use cfoundry with this feature without vmc:
cfclient = CFoundry::Client.new(target) cfclient.log = [] ... # later txlog = cfclient.log.map do |x| ... end

https://twitter.com/marklucovsky/status/253000106591264769

Dr Nic said...

I don't see anything in latest vmc/ng about "~/.vmc/use-ng" to activate it. What is the latest method for activiting v2 features?

Dr Nic said...

I think I've successfully switched to v2, by changing :version in ~/.vmc/tokens.yml for http://api.cloudfoundry.com.

Dr Nic said...

No, I don't think that's right. Now getting errors in most CLI commands.

Is there a different API hostname for v2?

jambay said...

Dr Nic, if the ~/.vmc/use-ng file is there, then you will be using vmc-ng which you can see by the "vmc -v" output. If you remove the ~/.vmc/use-ng then vmc will revert to classic vmc. vmc-ng determines which cloud controller features to use by looking at the output of the cloud controller /info endpoint. For example, api.cloudfoundry.com/info will show that it is a v1 cloud controller as of this comment. When using cc-ng on the server side, the /info endpoint returns information that it supports additional features.

Ruchir Rathore said...

Hi guys,

SpringOne India 2012 is here. Be part of one of the year's premier Java events happening in Bangalore & Hyderabad on 11th and 13th December 2012 respectively.
For more details about the event visit: bit.ly/Ungkqd
SpringOne 2012 is a one-of-a-kind conference for application developers, solution architects, web operations and IT teams who develop business applications, create multi-device aware web applications, design cloud architectures, and manage high performance infrastructure.

InnomaxMediaLLP said...

The information and the detail were just perfect. I think that your perspective is deep, its just well thought out and really fantastic.
Web developer Singapore

jos ken said...

The information about tehse will work for will be great.
Twin Cities Web Design

jos ken said...

Northfield Web Design where it can help with some basic ideas about these solutions.