Class: PoolParty::Installers::Ec2
Instance Method Summary
collapse
#closing_message, #initialize, #welcome_message
Methods included from Pinger
included
Methods included from Remote
#are_any_nodes_exceeding_minimum_runtime?, #are_too_few_instances_running?, #are_too_many_instances_running?, available, #execute!, #list_of_instances, #list_of_nodes_exceeding_minimum_runtime, #netssh, #nodes, #remote_rsync_command, #remote_ssh_array, #remote_ssh_string, #rsync, #rsync_command, #rsync_storage_files_to, #rsync_storage_files_to_command, #rsync_to, #rsync_to_command, #run_command_on, #run_command_on_command, #run_command_on_instance_number, #run_local, #run_remote, #scp_array, #scp_to_command, #simplest_run_remote, #ssh_array, #ssh_command, #ssh_into, #ssh_into_instance_number, #ssh_options, #ssh_string, #target_host
Instance Method Details
5
6
7
8
9
10
11
|
# File 'lib/poolparty/installers/ec2.rb', line 5
def commands
[
:get_access_key, :get_secret_access_key, :show_cert_message,
:get_keypair, :write_clouds_rb
]
end
|
#get_access_key ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/poolparty/installers/ec2.rb', line 13
def get_access_key
key_help_str = <<-EOE
Now you need to get your keys from Amazon AWS.
If you don't already have your keys setup, navigate to http://aws.amazon.com
and click on Your Account. Click on the Access Identifiers tab and find:
Your Access Key ID. This is your access key.
EOE
access_key_str = <<-EOE
Since you'll be using ec2, we'll have to set some things up before
we can get going on PoolParty. Don't worry, this information will stay between us.
EOE
say access_key_str
ask_with_help :message => "First, what's your access key?",
:help => key_help_str do |t|
@access_key = t
end
end
|
68
69
70
71
72
73
|
# File 'lib/poolparty/installers/ec2.rb', line 68
def get_ec2_api_tools
url = "http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&categoryID=88"
download_url = "http://www.amazon.com/gp/redirect.html/ref=aws_rc_ec2tools?location=http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip&token=A80325AA4DAB186C80828ED5138633E3F49160D9"
require 'open-uri'
::File.open("ec2-commandline-tools.zip", "w") {|f| f << open(download_url).read }
end
|
#get_keypair ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/poolparty/installers/ec2.rb', line 75
def get_keypair
begin
ec2 = PoolParty::Remote::Ec2.ec2({:access_key => @access_key, :secret_access_key => @secret_access_key})
keypairs = ec2.describe_keypairs["keySet"]["item"]
keynames = keypairs.map {|k| k["keyName"]}
rescue Exception => e
colored_say "There was an error: #{e}. Recheck your access_key and secret_access_key to make sure you copied them correctly"
exit 1
end
key_str =<<-EOK
Finally, what's the name of the keypair you'd like to use?
You already have the following keypairs setup:
\t#{keynames.join("\n\t")}
You can use one of these keys, or create a new one.
EOK
key_str_help =<<-EOH
To make a new keypair, make sure you have the ec2 tools installed. You can create a new one by typing the command:
ec2-add-keypair
Save this into a file in your ~/.ec2 directory. Enter the name of the keypair here.
EOH
ask_with_help :message => key_str,
:help => key_str_help do |t|
@keypair = t
say <<-EOE
In your clouds.rb, you can use this keypair in your clouds.
Create one for each cloud you want to use.
EOE
end
end
|
#get_secret_access_key ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/poolparty/installers/ec2.rb', line 32
def get_secret_access_key
key_help_str = <<-EOE
If you don't already have your keys setup, navigate to http://aws.amazon.com
and click on Your Account. Click on the Access Identifiers tab and find:
Your Secret Access Key ID. Click on the - show button.
This is your secret access key.
EOE
ask_with_help :message => "Awesome. Now what's your secret access key? ",
:help => key_help_str do |t|
@secret_access_key = t
end
end
|
#show_cert_message ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/poolparty/installers/ec2.rb', line 45
def show_cert_message
rescued_ask_str = <<-EOS
Super duper! You'll need to make sure you have yout X.509 certificate downloaded too.
Save this in your ~/.ec2 directory.
Press enter when you're ready
EOS
cert_help_str = <<-EOE
To get your X.509 certificates, navigate to http://aws.amazon.com and login. Click on
Your Account and scroll down. The X.509 Certificate box is at the bottom. Make sure you
click download and save the cert-*.pem file. If you don't know or don't have the pk-*.pem file
you may have to recreate it. Not to worry though, it's super easy. Click on the Create New button.
From there, you can download the cert-*.pem and the pk-*.pem files.
EOE
ask_with_help :message => rescued_ask_str,
:help => cert_help_str do |t|
@cert = true
end
end
|
#write_clouds_rb ⇒ Object
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/poolparty/installers/ec2.rb', line 114
def write_clouds_rb
clds =<<-EOC
pool :my_pool do
cloud :my_app do
# Copy these lines and source them in your .profile or .bashrc file
# export AWS_ACCESS_KEY="#{@access_key}"
# export AWS_SECRET_ACCESS_KEY="#{@secret_access_key}"
# export EC2_PRIVATE_KEY=$(ls ~/.ec2/pk-*.pem)
# export EC2_CERT=$(ls ~/.ec2/cert-*.pem)
access_key "#{@access_key}"
secret_access_key "#{@secret_access_key}"
keypair "#{@keypair}"
has_file "/etc/motd" do
content "Welcome to your first PoolParty instance!"
end
end
end
EOC
::File.open("clouds.rb", "w") {|f| f << clds}
end
|