CFoundry Helper

This collection of scripts provides helper methods to the cfoundry gem’s API. It implements common use cases when administrating a Cloud Foundry installation.

Configuration

You can configure multiple targets within the services.yml configuration file. Please refer to the services.yml.example file for a detailed example.

Usage

Since cfoundry_helper now supports multiple CF targets you have to set your desired target by using the CFoundryHelper::Helpers::ClientHelper.current_target_url= method for selecting a target from your service configuration file.

Organization management

The CFoundryHelper::Helpers::OrganizationHelper modules’ methods provide helper methods for the following use cases:

  • create organizations
  • add/remove Users from organizations
  • administer User roles within organizations

User management

The CFoundryHelper::Helpers::UserHelper module provides methods for managing users within the system:

  • get user by email
  • create a user
  • delete a user
  • change a user’s password

Space management

The CFoundryHelper::Helpers::OrganizationHelper modules’ methods provide helper methods for the following use cases:

  • create a space within an organization
  • add/remove Users from spaces
  • administer User roles within a space
  • empty a space (remove all apps, service_bindings, service_instances, routes and domains from the space)
  • delete a space

Client Helper

The CFoundryHelper::Helpers::ClientHelper is a factory for uaa and cloud controller clients. The current_target_url has to point to your desired endpoint as defined in the config yaml file.

Scripts

  • bin/add_users_to_org : adds users to an organization
    • usage : RAILS_ENV=<test / production / development> bundle exec bin/add_users_to_org
  • bin/create_space_for_org : creates a space to an organization and assigns all organization members to it
    • usage : RAILS_ENV=<test / production / development> bundle exec bin/create_space_for_org

Important environment variables

  • RAILS_ENV : The helper is reading the target environment on which to execute commands using the RAILS_ENV environment variable. (e.g. production, test)
  • CFOUNDRY_HELPER_CONFIG This variable has to point to your services.yml file.

Console Usage

Use the following command to start the console: RAILS_ENV= CFOUNDRY_HELPER_CONFIG= rake c

e.g.: RAILS_ENV=production CFOUNDRY_HELPER_CONFIG=config/services.yml rake c