From: Jan Provaznik jprovazn@redhat.com
Instance SSH key name is now unique (had same name as cloud account key till now) --- src/app/models/instance.rb | 8 ++++++++ src/app/models/instance_key.rb | 2 ++ src/dbomatic/dbomatic | 5 +---- 3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb index 1172998..281694a 100644 --- a/src/app/models/instance.rb +++ b/src/app/models/instance.rb @@ -187,6 +187,14 @@ class Instance < ActiveRecord::Base end end
+ def copy_cloud_account_key + return unless self.cloud_account and self.cloud_account.instance_key + new_key = InstanceKey.new(self.cloud_account.instance_key.attributes) + new_key.instance_key_owner = self + new_key.name = "#{self.name}_rsa_#{Time.now.to_f}" + new_key.save! + end + def self.get_user_instances_stats(user) stats = { :running_instances => 0, diff --git a/src/app/models/instance_key.rb b/src/app/models/instance_key.rb index 3ec3e51..d3d2892 100644 --- a/src/app/models/instance_key.rb +++ b/src/app/models/instance_key.rb @@ -27,6 +27,8 @@ class InstanceKey < ActiveRecord::Base
belongs_to :instance_key_owner, :polymorphic => true
+ # TODO: this is ec2 specific, create more general ProviderType model, + # this will have type, ssh_user, and optionally homedir fields. REMOTE_USER = 'ec2-user' REMOTE_HOME = '/home/ec2-user'
diff --git a/src/dbomatic/dbomatic b/src/dbomatic/dbomatic index e021ff6..5f33aab 100755 --- a/src/dbomatic/dbomatic +++ b/src/dbomatic/dbomatic @@ -212,10 +212,7 @@ class CondorEventLog < Nokogiri::XML::SAX::Document # FIXME: we are updating the instance_key_id here, but this is really not # the right way or place to do this. This will have to be revisited when # we come up with a real key management architecture - new_key = InstanceKey.new(cloud_account.instance_key.attributes) - new_key.instance_key_owner = inst - new_key.save! - inst.instance_key = new_key + inst.copy_cloud_account_key
inst.save! end