Spring Roo Add-on for Cloud Foundry
Cloud Foundry is an open source PaaS cloud solution from SpringSource, the same organization behind the Spring Roo framework, a next-generation rapid application development tool for Java developers. Cloud Foundry allows the deployment of applications written using Spring, Rails, and other modern frameworks. This article explains how to install and use the Cloud Foundry Roo add-on component.
This article is based on Spring Roo in Action, published in April 2012. It is being reproduced here by permission from Manning Publications. Manning early access books and ebooks are sold exclusively through Manning. Visit the book’s page for more information.
Authors: Ken Rimple and Srini Penchikala with Gordon Dickens
Â The Cloud Foundry add-on is well integrated with Cloud Foundry services. Using the Roo add-on commands, you can perform various Cloud Foundry tasks, such as logging in to Cloud Foundry, viewing the already deployed applications, binding to services, and deploying new applications. There are several Cloud Foundry commands added to the Spring Roo shell to make it easy to view, deploy, and monitor your cloud applications. Letâ€™s look at how to install the Cloud Foundry add-on so you can start issuing the commands provided by the add-on component.
How to install the Cloud Foundry add-on
Before you start developing Roo applications to deploy to the cloud, you need to create an account on Cloud Foundry. You can do this by signing up for a CloudFoundry.com account at http://www.cloudfoundry.com/. Using the new credentials you receive from the Cloud Foundry team, you can log in to the website to deploy applications to the cloud. You can also download the virtual image of Micro Cloud Foundry to test the applications locally on your PC or Mac.
To get started, you need to run the pgpautomatictrust command to enable automatic PGP key trusting and ensure that the signed bundles needed by the Cloud Foundry add-on can be installed on your system. Because you donâ€™t want to leave the system with this setting, as soon as the add-on files are installed, you should disable the automatic PGP trusting by running the same command again:
pgp automatic trust
Hereâ€™s the output of the pgp command:
roo> pgp automatic trust
Automatic PGP key trusting enabled (this is potentially unsafe); ?
disable by typing 'pgp automatic trust' again roo>
Then you run the addon install command to instruct Roo to download and install the Cloud Foundry support. When you see the â€śDeploying…done. Successfully installed add-on: Spring Roo – Addon – Cloud Foundry [version: 1.1.5.RELEASE]â€ť message on your screen, youâ€™ll know youâ€™ve successfully installed Cloud Foundry support:
addon install bundle --bundleSymbolicName org.springframework.roo. ?
This command takes a few minutes to download all of the required JAR files. Hereâ€™s the output of the add-on install command:
roo> addon install bundle --bundleSymbolicName org.springframework. ?
Spring Roo - Addon - Cloud Foundry (1.1.5.RELEASE)
Spring Beans (3.0.5.RELEASE)
Spring AOP (3.0.5.RELEASE)
Servlet Specification API (2.5.0)
Spring Core (3.0.5.RELEASE)
Jackson JSON processor (1.6.2)
Data mapper for Jackson JSON processor (1.6.2)
Spring Context (3.0.5.RELEASE)
Spring Roo - Wrapping - aopalliance (1.0.0.0010)
Spring Web (3.0.5.RELEASE)
Spring Roo - Wrapping - Cloud Foundry API (0.0.1.0010)
Spring Expression Language (3.0.5.RELEASE)
Spring ASM (3.0.5.RELEASE)
Successfully installed add-on: Spring Roo - Addon - Cloud Foundry ?
[Hint] Please consider rating this add-on with the following command:
[Hint] addon feedback bundle --bundleSymbolicName org.springframework.? roo.addon.cloud.foundry --rating ... --comment "..."
Now, type the pgpautomatic trust command again to disable key trusting. Hereâ€™s the output of this command showing the PGP key trusting is now disabled:
roo> pgp automatic trust
Automatic PGP key trusting disabled (this is the safest option)
Youâ€™re ready to execute the Cloud Foundry commands. Type in the command cloud foundry and press TAB twice. Youâ€™ll see displayed the available Cloud Foundry commands, as shown in the following snippet:
roo> cloud foundry
cloud foundry clear cloud foundry login
Now that youâ€™ve installed Cloud Foundry support, you can begin to issue any of the 30-plus Cloud Foundry Roo add-on commands to perform various tasks in the cloud application development lifecycle. Next, youâ€™ll find more details about some of these commands and learn how to use them to deploy and run your application in the Cloud Foundry server environment.
As you can see in the following example, the Cloud Foundry add-on offers various commands to manage the applications on the cloud server instances. These commands are used for different tasks to deploy and monitor cloud applications:
cloud foundry bind service
cloud foundry clear login details
cloud foundry create service
cloud foundry delete app
cloud foundry delete service
cloud foundry deploy
cloud foundry files
cloud foundry info
cloud foundry list apps
cloud foundry list instances
cloud foundry list services
cloud foundry login
cloud foundry map url
cloud foundry restart app
cloud foundry start app
cloud foundry stop app
cloud foundry unbind service
cloud foundry unmap url
cloud foundry update app memory
cloud foundry view app memory
cloud foundry view app stats
cloud foundry view crashes
cloud foundry view crash logs
cloud foundry view logs
Youâ€™ll use the key commands required to deploy your sample application. Youâ€™ll use commands to log in to Cloud Foundry website, deploy the new application, and verify that the application has been deployed correctly. Youâ€™ll also test the application from the Cloud Foundry site using the application URL you specify during the deployment step. The following part provides a step-by-step approach to all of the add-on commands youâ€™ll use in the application deployment process.
Cloud Foundry also offers a command-line interface (CLI) called vmc, which allows you to interact with the Cloud Foundry instance from the command shell.
Cloud Foundry command-line interface
With the vmc tool you can deploy Java-, Ruby-, and Node.js-based web applications to the Cloud Foundry servers. You can also configure the deployed applications to use the built-in services provided by the Cloud Foundry platform.
The interface is written in Ruby, so youâ€™ll need Ruby and Ruby Gem installed before you can use the CLI commands. The following list contains the vmc commands you can use to deploy and manage the applications in Cloud Foundry:
vmc instances 3
For more information on the vmc tool, check the support page (http://mng.bz/SfWG) on the Cloud Foundry community website. You now have the add-on installed and ready for use.
You learned about Cloud Foundry, the cloud computing product from VMware, and how to install the Cloud Foundry add-on in Roo.
Cloud Foundry is based on the open source PaaS cloud computing model and has great potential to innovate in the cloud computing space. It allows developers to increase their productivity without getting bogged down with infrastructure setup and maintenance overhead. Cloud Foundryâ€™s integration with Roo gives you the ability to develop applications on your local development environment (which should be easier when you use Micro Cloud Foundry), and the means to deploy and manage applications, all from within the Roo command shell.