cloudsoft.io

Creating First Location

Creating first location

Locations in Cloudsoft AMP are server resources which AMP can use to deploy applications. These locations may be servers or cloud providers which provide access to servers.

A standard location catalog for AWS could look like the following.

brooklyn.catalog:
  version: 1.0.0
  items:
  - id: amazon-anywhere
    itemType: location
    item:
      type: jclouds:aws-ec2
      brooklyn.config:
        displayName: AWS (any region)
        identity: ABCDEFGHIJKLMNOPQRST
        credential: s3cr3tsq1rr3ls3cr3tsq1rr3ls3cr3tsq1rr3l
  - id: amazon-us-east-1
    itemType: location
    item:
      type: amazon-anywhere
      brooklyn.config:
        displayName: AWS Virginia
        region: us-east-1
  - id: amazon-us-west-1
    itemType: location
    item:
      type: amazon-anywhere
      brooklyn.config:
        displayName: AWS California
        region: us-west-1

In here we describe 3 locations. One that can be used to target any amazon location (you would then need to configure a region when you deployed a blueprint). This location has an Amazon key and identity. To use the blueprint replace these values with your own. The other two locations extend this basic location by adding region config.

To add these locations to your catalog save the yaml to a file called amazon-locations.bom and run the following command (which uses the Cloudsoft AMP CLI):

br add-catalog amazon-locations.bom

This location will now be available to any application you launch through Cloudsoft AMP. You can see a list of currently available locations using the cli with:

br catalog

Included in the list should be the amazon entities you just added.

Id                 Name                       Spec
...
amazon-anywhere    amazon-anywhere            brooklyn.catalog:amazon-anywhere:1.0.0
amazon-us-east-1   amazon-us-east-1           brooklyn.catalog:amazon-us-east-1:1.0.0
amazon-us-west-1   amazon-us-west-1           brooklyn.catalog:amazon-us-west-1:1.0.0
...

As with entity catalogs you can version locations and set readable names, ids, and descriptions.

To use one the locations add the location id to your application yaml with the top level location key.

name: location test
location: amazon-us-east-1
services:
- type: org.apache.brooklyn.entity.software.base.EmptySoftwareProcess
  id: empty

Save this yaml to test-amazon-location.yaml and deploy with:

br deploy test-amazon-location.yaml

This will provision and configure a vm then test SSH access but it will not deploy any apps.

Testing our deployed application

We should now wait until our application has deployed (or failed to deploy).

br application "location test"

Running the following command will let us know the state of our application.

br application "location test"

Id:              cb69jpljes
Name:            location test
Status:          STARTING
ServiceUp:       false
Type:            org.apache.brooklyn.entity.stock.BasicApplication
CatalogItemId:
LocationId:      gaix92akwi
LocationName:    AWS Virginia
LocationSpec:    jclouds:aws-ec2
LocationType:    org.apache.brooklyn.location.jclouds.JcloudsLocation

As we can see our application has not yet started. We could keep running the same command until we see that our application is ready or we could run something like the following to watch this for us.

br application "location test" | grep STARTING
while [ $? -eq 0 ]; do !!; done ; bp

Now that the application is running we want to make sure that the provisioned VM is accessible. Within our application are the entities that make it up. If an entity has been deployed on a host then it will contain a host.sshAddress sensor with details of how to connect to the host.

To see the entities that make up our app we run:

br application "location test" entity

Id           Name                        Type
mlbnk1bf7e   EmptySoftwareProcess:mlbn   org.apache.brooklyn.entity.software.base.EmptySoftwareProcess

As we might expect there is only a single entity in our app which is an empty software process that has been “deployed” to an AWS VM. We will want to look at its sensors for the host.sshAdress sensor.

br application "location test" entity mlbnk1bf7e sensor

Name                                   Description                                                                                         Value
download.addon.urls                    URL patterns for downloading named add-ons (will substitute things like ${version} automatically)   null
download.url                           URL pattern for downloading the installer (will substitute things like ${version} automatically)    null
expandedinstall.dir                    Directory for installed artifacts (e.g. expanded dir after unpacking .tgz)                          null
host.address                           Host IP address                                                                                     50.19.22.101
host.name                              Host name                                                                                           ec2-50-19-22-101.compute-1.amazonaws.com
host.sshAddress                        user@host:port for ssh'ing (or null if inappropriate)                                               ampuser@ec2-50-19-22-101.compute-1.amazonaws.com:22
host.subnet.address                    Host address as known internally in the subnet where it is running (if different to host.name)      10.165.155.118
host.subnet.hostname                   Host name as known internally in the subnet where it is running (if different to host.name)         ec2-50-19-22-101.compute-1.amazonaws.com
install.dir                            Directory for this software to be installed in                                                      /home/users/ampuser/brooklyn-managed-processes/installs/EmptySoftwareProcess
run.dir                                Directory for this software to be run from                                                          /home/users/ampuser/brooklyn-managed-processes/apps/cb69jpljes/entities/EmptySoftwareProcess_mlbnk1bf7e
service.isUp                           Whether the service is active and availability (confirmed and monitored)                            true
service.notUp.diagnostics              A map of namespaced diagnostics, from when the service is not up                                    {}
service.notUp.indicators               A map of namespaced indicators that the service is not up                                           {}
service.process.isRunning              Whether the process for the service is confirmed as running                                         true
service.state                          Actual lifecycle state of the service                                                               RUNNING
service.state.expected                 Last controlled change to service state, indicating what the expected state should be               running @ 1467965495843 / Fri Jul 08 09:11:35 BST 2016
softwareprocess.pid.file               PID file                                                                                            null
softwareservice.provisioningLocation   Location used to provision a machine where this is running                                          {"id":"gaix92akwi","type":"org.apache.brooklyn.api.location.Location"}

We can see the host.sshAddress value in the above table. If we use the value, replacing the : with -p for ssh, we can run the following command.

ssh ampuser@ec2-50-19-22-101.compute-1.amazonaws.com -p 22

Assuming this works we will see a command prompt on our provisioned VM. At this point we might want to provision a more complex blueprint to further test our location.

This section of the documentation has provided a short, stepped, introduction into locations. The following sections provide a reference for locations and the differences between different cloud providers, how to write java to customize locations, and how to troubleshoot issues with a location.