Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: adamwiggins/sumo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: thinkcreate/sumo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Sep 11, 2009

  1. make keypair region specific

    eval committed Sep 11, 2009
    Copy the full SHA
    c1ef3ca View commit details
  2. Copy the full SHA
    d2ede9e View commit details
Showing with 19 additions and 8 deletions.
  1. +4 −4 README.rdoc
  2. +1 −1 bin/sumo
  3. +14 −3 lib/sumo.rb
8 changes: 4 additions & 4 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ Optional config you can include any of the following in your config.yml:

user: root
ami: ami-ed46a784
availability_zone: us-east-1b
availability_zone: us-east-1b
cookbooks_url: git://github.com/adamwiggins/chef-cookbooks.git

You'll need Bacon and Mocha if you want to run the specs, and Jewler if you want to create gems.
@@ -64,9 +64,9 @@ You'll need Bacon and Mocha if you want to run the specs, and Jewler if you want
Create and attach a volume to your running instance:

$ sumo create_volume
---> Create 5MB volume... vol-8a9c6ae3 (1.1s)
---> Create 5GB volume... vol-8a9c6ae3 (1.1s)
$ sumo volumes
vol-8a9c6ae3 5MB available
vol-8a9c6ae3 5GB available
$ sumo attach
---> Attach vol-8a9c6ae3 to i-bc32cbd4 as /dev/sdc1... done (0.6s)

@@ -85,7 +85,7 @@ Log in to format and mount the volume:

To detach from a running instance (perhaps so you can attach elsewhere):

$ sumo detatch
$ sumo detach
---> Detach vol-8a9c6ae3... done (0.6s)

Destroy it if you no longer want the data stored on it:
2 changes: 1 addition & 1 deletion bin/sumo
Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@ class CLI < Thor
end
end

desc "create_volume [<megabytes>]", "create a volume"
desc "create_volume [<gigabytes>]", "create a volume"
def create_volume(size=5)
task("Create #{size}GB volume") { sumo.create_volume(size) }
end
17 changes: 14 additions & 3 deletions lib/sumo.rb
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ def launch
result = ec2.run_instances(
:image_id => ami,
:instance_type => config['instance_size'] || 'm1.small',
:key_name => 'sumo',
:key_name => key_name,
:group_id => [ 'sumo' ],
:availability_zone => config['availability_zone']
)
@@ -235,13 +235,24 @@ def read_config
rescue Errno::ENOENT
raise "Sumo is not configured, please fill in ~/.sumo/config.yml"
end

def current_region
@current_region ||= begin
zones = ec2.describe_availability_zones
zones.availabilityZoneInfo.item[0].regionName
end
end

def keypair_file
"#{sumo_dir}/keypair.pem"
"#{sumo_dir}/keypair-#{current_region}.pem"
end

def key_name
"sumo-#{current_region}"
end

def create_keypair
keypair = ec2.create_keypair(:key_name => "sumo").keyMaterial
keypair = ec2.create_keypair(:key_name => key_name).keyMaterial
File.open(keypair_file, 'w') { |f| f.write keypair }
File.chmod 0600, keypair_file
end