Roo add-on for Cloud Foundry

Một phần của tài liệu Manning spring roo in action (Trang 361 - 364)

The Cloud Foundry add-on3 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 com­

mands 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.

13.3.1 How to install the Cloud Foundry add-on

Before you start developing Roo applications to deploy to the cloud, you need to cre­

ate an account on Cloud Foundry. You can do this by signing up for a Cloud­

Foundry.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 pgp automatic trust command to enable auto­

matic 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]” mes­

sage on your screen, you’ll know you’ve successfully installed Cloud Foundry support:

addon install bundle --bundleSymbolicName org.springframework.roo. ➥

addon.cloud.foundry

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. ➥

roo.addon.cloud.foundry Target resource(s):

3 Available since the Roo 1.1.3 release.

---

---

---

329 Roo add-on for Cloud Foundry

Spring Roo - Addon - Cloud Foundry (1.1.5.RELEASE) Required resource(s):

Spring Beans (3.0.5.RELEASE) jcl-over-slf4j (1.6.1) slf4j-nop (1.6.1)

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)

slf4j-api (1.6.1)

Spring Roo - Wrapping - Cloud Foundry API (0.0.1.0010) Optional resource(s):

Spring Expression Language (3.0.5.RELEASE) Spring ASM (3.0.5.RELEASE)

Deploying...done.

Successfully installed add-on: Spring Roo - Addon - Cloud Foundry ➥

[version: 1.1.5.RELEASE]

[Hint] Please consider rating this add-on with the following command:

[Hint] addon feedback bundle --bundleSymbolicName org.springframework.➥

roo.addon.cloud.foundry --rating ... --comment "..."

roo>

Now, type the pgp automatic 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) roo>

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 com­

mands, 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. In the next section, you’ll find more details about some of these commands and learn how to use them to deploy and run your applica­

tion in the Cloud Foundry server environment.

13.3.2 Add-on commands

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 com­

mands 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 section provides a step-by-step approach to all of the add-on com­

mands 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.

13.3.3 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 info vmc apps vmc services

331 Deploying the Course Manager application to the cloud

vmc frameworks vmc runtimes cd myapp

vmc push <appname>

vmc instances <appname>

vmc instances <appname> 3

vmc create-service <service> <name> <app>

bind-service <servicename> <appname>

update <appname>

map <appname> <url>

logs <appname>

stats <appname>

target <url>

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. Let’s see how to deploy the sample application using the new Cloud Foundry add-on commands.

Một phần của tài liệu Manning spring roo in action (Trang 361 - 364)

Tải bản đầy đủ (PDF)

(406 trang)