class Drupal_Clusting
Public methods of this class are just the CLI commands. Its private methods are separated into modules.
Public Class Methods
# File bin/drupalcluster, line 50 def initialize read_conf_file read_stacks_json end
Public Instance Methods
Terminate one of the Drupal servers, referred by its instance_id.
The EC2 instance-id of the currently active server is displayed e.g. on the top of the PHP page that has the same URL but without “/drupal” at the end
Example:¶ ↑
drupalcluster attack i-0a68ac21dd859867b
# File bin/drupalcluster, line 157 def attack instance_id puts "We are about to _terminate_ server instance '#{instance_id}'." confirm AMA::terminate instance_id puts "Terminating instance.." end
Gives status about creation/deletion of the given cluster. Possible results are:
ongoing, created, failed, stack does not exist
If the cluster is successfully created, check also provides its URL and database info
Examples:
drupalcluster check -- checks the last initiated creation/deletion drupalcluster check MySite -- checks processing of site called 'MySite'
# File bin/drupalcluster, line 131 def check stack_name=nil stack_name = previous unless stack_name puts "Checking stack #{stack_name}." res = AMA::stack_status stack_name puts res if :created == res outputs = AMA::info stack_name display_outputs( outputs ) if @stacks[stack_name] != outputs['WebsiteURL'] @stacks[stack_name] = outputs['WebsiteURL'] write_stacks_json end end end
Creates a Drupal cluster. You have to give it a name as parameter, and then a password for the DB admin. The process may take 10-15 minutes. If deployment was successful, the website URL and database details are displayed.
Example:¶ ↑
drupalcluster create MySite
# File bin/drupalcluster, line 65 def create stack_name @conf[:create][:stack_name] = stack_name @conf[:create_params]["DBPassword"] ||= get_password # generate key of name KeyName if not yet puts "Creating drupal cluster '#{stack_name}', may take a while.." puts "Ctrl-C will not stop the creation." created = AMA::create_stack @conf if created display_outputs(created) @stacks[stack_name] = created['WebsiteURL'] write_stacks_json end end
Deletes the given cluster after confirmation.
Example:¶ ↑
drupalcluster delete MySite
# File bin/drupalcluster, line 85 def delete stack_name puts "No way back. All users and contents will be lost." confirm AMA::delete_stack stack_name puts "Deletion initiated. Use following command to see if it is finished:" puts " #{$PROGRAM_NAME} check #{stack_name}" put_at_the_end stack_name end
Describes the given command.
# File bin/drupalcluster, line 180 def help cmd=nil puts puts get_comment_above( cmd, __FILE__ ) end
Tests the given site by a simple HTTP GET /. Either the cluster name or the Drupal site's base URL has to be specified as parameter.
Examples:¶ ↑
drupalcluster test -- tests the last created/deleted site drupalcluster test MySite -- tests site called 'MySite' drupalcluster test http://xy.com/drupal -- tests given URL
# File bin/drupalcluster, line 104 def test stack=nil stack_url = stack if stack !~ /https?:|\.amazonaws\./ stack_name = stack or previous stack_url = @stacks[stack_name] end die("An http[s] URL or a previously created stack name is required." ) unless stack_url stack_url = stack_url.sub /\/drupal\/?/, '' puts "Sending request to #{stack_url}" http = Netting.new stack_url res = http.get '' puts "Result code is: #{res.code}" if res.respond_to? :code end