--- server/lib/deltacloud/base_driver/features.rb | 15 +++++++++++++++ server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 8 +++++++- server/views/instances/new.html.haml | 12 +++++++++--- server/views/instances/show.html.haml | 5 +++++ server/views/instances/show.xml.haml | 3 +++ 5 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/server/lib/deltacloud/base_driver/features.rb b/server/lib/deltacloud/base_driver/features.rb index 43ec9c3..f4f456e 100644 --- a/server/lib/deltacloud/base_driver/features.rb +++ b/server/lib/deltacloud/base_driver/features.rb @@ -136,6 +136,21 @@ module Deltacloud end end
+ declare_feature :instances, :authentification_key do + operation :create do + param :keyname, :string, :optional, nil + "EC2 key authentification method" + end + operation :show do + end + end + + declare_feature :instances, :authentification_password do + operation :create do + param :password, :string, :optional + end + end + declare_feature :instances, :hardware_profiles do description "Size instances according to changes to a hardware profile" # The parameters are filled in from the hardware profiles diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb index 69356e2..d2152db 100644 --- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb +++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb @@ -19,12 +19,17 @@ require 'deltacloud/base_driver' require 'AWS'
+class Instance + attr_accessor :keyname +end + module Deltacloud module Drivers module EC2 class EC2Driver < Deltacloud::BaseDriver
feature :instances, :user_data + feature :instances, :authentification_key
define_hardware_profile('m1-small') do cpu 1 @@ -156,7 +161,7 @@ class EC2Driver < Deltacloud::BaseDriver ec2_instances = ec2.run_instances( :image_id => image.id, :user_data => opts[:user_data], - :key_name => opts[:key_name], + :key_name => opts[:keyname], :availability_zone => realm_id, :monitoring_enabled => true, :instance_type => hwp.name.tr('-', '.'), @@ -278,6 +283,7 @@ class EC2Driver < Deltacloud::BaseDriver :flavor_id=>ec2_instance['instanceType'].gsub( /./, '-'), :instance_profile =>InstanceProfile.new(hwp_name), :actions=>instance_actions_for( state ), + :keyname => ec2_instance['keyName'] } ) end
diff --git a/server/views/instances/new.html.haml b/server/views/instances/new.html.haml index c746475..25d8689 100644 --- a/server/views/instances/new.html.haml +++ b/server/views/instances/new.html.haml @@ -5,9 +5,15 @@
%form{ :action => instances_url, :method => :post } %input{ :name => :image_id, :type => :hidden, :value => @instance.image_id }/ - %label - Instance Name: - %input{ :name => 'name', :size => 30 }/ + %p + %label + Instance Name: + %input{ :name => 'name', :size => 30 }/ + -if driver_has_feature(:authentification_key) + %p + %label + Instance Keyname: + %input{:name => 'keyname', :size => 30 } - if !@hardware_profiles.empty? %h3 What size machine? - for hwp in @hardware_profiles diff --git a/server/views/instances/show.html.haml b/server/views/instances/show.html.haml index dabcc61..ebbdd2a 100644 --- a/server/views/instances/show.html.haml +++ b/server/views/instances/show.html.haml @@ -36,6 +36,11 @@ %dt Private Addresses %dd = @instance.private_addresses.collect { |address| "<div>#{address}</div>" }.join + - if driver_has_feature?(:authentification_key) + %di + %dt Keyname + %dd + = @instance.keyname %di %dt %dd diff --git a/server/views/instances/show.xml.haml b/server/views/instances/show.xml.haml index a4859b0..9dc513b 100644 --- a/server/views/instances/show.xml.haml +++ b/server/views/instances/show.xml.haml @@ -26,3 +26,6 @@ - @instance.private_addresses.each do |address| %address< =address + - if driver_has_feature?(:authentification_key) + %keyname< + =@instance.keyname