mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-19 11:22:55 +09:00
feature #1508: Add --keypair option to econe-run-instances
(cherry picked from commit 8a0dbcd9965def8f4ff19e533b03f13f048729f5)
This commit is contained in:
1 parent
b787b2bd85
commit
7aea64f2a6
2 files changed
+22
-15
No files matched your search
@@ -51,6 +51,14 @@ TYPE = {
|
||||
:format => String
|
||||
}
|
||||
|
||||
KEYNAME = {
|
||||
:name => "keypair",
|
||||
:short => "-k keypair",
|
||||
:large => "--keypair keypair",
|
||||
:description => "The name of the key pair.",
|
||||
:format => String
|
||||
}
|
||||
|
||||
INSTANCE_COUNT = {
|
||||
:name => "instance_count",
|
||||
:large => "--instance-count count",
|
||||
@@ -110,7 +118,8 @@ EOT
|
||||
EC2QueryClient::URL,
|
||||
USER_DATA,
|
||||
INSTANCE_COUNT,
|
||||
TYPE
|
||||
TYPE,
|
||||
KEYNAME
|
||||
]
|
||||
|
||||
main :image_id do
|
||||
@@ -129,11 +138,12 @@ EOT
|
||||
options[:max_count] ||= options[:min_count]
|
||||
|
||||
rc = ec2_client.run_instances(
|
||||
args[0],
|
||||
options[:type],
|
||||
options[:user_data],
|
||||
options[:min_count],
|
||||
options[:max_count])
|
||||
:image_id => args[0],
|
||||
:instance_type => options[:type],
|
||||
:user_data => options[:user_data],
|
||||
:min_count => options[:min_count],
|
||||
:max_count => options[:max_count],
|
||||
:key_name => options[:keypair])
|
||||
|
||||
if CloudClient::is_error?(rc)
|
||||
exit_with_code -1, "#{cmd_name}: #{rc.message}"
|
||||
|
||||
@@ -133,16 +133,13 @@ module EC2QueryClient
|
||||
# :image_id
|
||||
# :instance_type
|
||||
######################################################################
|
||||
def run_instances(ami_id, type, user_data=nil, min_count=1, max_count=1)
|
||||
def run_instances(opts)
|
||||
begin
|
||||
response = @ec2_connection.run_instances(
|
||||
:image_id => ami_id,
|
||||
:instance_type => type,
|
||||
:user_data => user_data,
|
||||
:base64_encoded => true,
|
||||
:min_count => min_count,
|
||||
:max_count => max_count
|
||||
)
|
||||
response = @ec2_connection.run_instances({
|
||||
:base64_encoded => true,
|
||||
:min_count => 1,
|
||||
:max_count => 1
|
||||
}.merge(opts))
|
||||
rescue Exception => e
|
||||
error = CloudClient::Error.new(e.message)
|
||||
return error
|
||||
|
||||
Reference in new issue
Block a user