mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-10 06:24:35 +09:00
feature #239: Added -d option for user_data
This commit is contained in:
1 parent
5a26d3fcf8
commit
1e5437bcb6
4 files changed
+17
-6
No files matched your search
@@ -68,6 +68,7 @@ opts = GetoptLong.new(
|
||||
['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--url', '-U',GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--type', '-t',GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--user-data', '-d',GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--headers', '-H',GetoptLong::NO_ARGUMENT]
|
||||
)
|
||||
|
||||
@@ -77,6 +78,7 @@ access = nil
|
||||
secret = nil
|
||||
auth = nil
|
||||
type = nil
|
||||
user_data = nil
|
||||
|
||||
begin
|
||||
opts.each do |opt, arg|
|
||||
@@ -93,6 +95,8 @@ begin
|
||||
type = arg
|
||||
when '--headers'
|
||||
headers = true
|
||||
when '--user-data'
|
||||
user_data = arg
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
@@ -119,7 +123,7 @@ rescue Exception => e
|
||||
exit -1
|
||||
end
|
||||
|
||||
rc = ec2_client.run_instances(image_id,type)
|
||||
rc = ec2_client.run_instances(image_id,type, user_data)
|
||||
|
||||
if CloudClient::is_error?(rc)
|
||||
puts "#{cmd_name}: #{rc.message}"
|
||||
|
||||
@@ -97,13 +97,15 @@ module EC2QueryClient
|
||||
# :image_id
|
||||
# :instance_type
|
||||
######################################################################
|
||||
def run_instances(ami_id, type)
|
||||
def run_instances(ami_id, type, user_data=nil)
|
||||
begin
|
||||
response = @ec2_connection.run_instances(
|
||||
:image_id => ami_id,
|
||||
:min_count => 1,
|
||||
:max_count => 1,
|
||||
:instance_type => type
|
||||
:image_id => ami_id,
|
||||
:min_count => 1,
|
||||
:max_count => 1,
|
||||
:instance_type => type,
|
||||
:user_data => user_data,
|
||||
:base64_encoded => true
|
||||
)
|
||||
rescue Exception => e
|
||||
error = CloudClient::Error.new(e.message)
|
||||
|
||||
@@ -211,11 +211,14 @@ class EC2QueryServer < CloudServer
|
||||
# Build the VM
|
||||
erb_vm_info=Hash.new
|
||||
|
||||
|
||||
erb_vm_info[:img_path] = image.path
|
||||
erb_vm_info[:img_id] = params['ImageId']
|
||||
erb_vm_info[:instance_type] = instance_type_name
|
||||
erb_vm_info[:template] = @config[:template_location] +
|
||||
"/#{instance_type['TEMPLATE']}"
|
||||
erb_vm_info[:user_data] = params['UserData']
|
||||
|
||||
template = ERB.new(File.read(erb_vm_info[:template]))
|
||||
template_text = template.result(binding)
|
||||
|
||||
|
||||
@@ -75,6 +75,8 @@ helpers do
|
||||
message = 'Specified AMI ID does not exist'
|
||||
when 'Unsupported'
|
||||
message = 'The instance type or feature is not supported in your requested Availability Zone.'
|
||||
else
|
||||
message = code
|
||||
end
|
||||
|
||||
xml = "<Response><Errors><Error><Code>"+
|
||||
|
||||
Reference in new issue
Block a user