From: Jozef Zigmund jzigmund@redhat.com
--- ...20110331152400_change_credential_definitions.rb | 48 ++++++++++++++++++++ src/db/seeds.rb | 8 ++-- 2 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 src/db/migrate/20110331152400_change_credential_definitions.rb
diff --git a/src/db/migrate/20110331152400_change_credential_definitions.rb b/src/db/migrate/20110331152400_change_credential_definitions.rb new file mode 100644 index 0000000..9206504 --- /dev/null +++ b/src/db/migrate/20110331152400_change_credential_definitions.rb @@ -0,0 +1,48 @@ +class ChangeCredentialDefinitions < ActiveRecord::Migration + def self.up + transform_credential_definitions + end + + def self.down + transform_credential_definitions_back + end + + def self.transform_credential_definitions + ec2 = ProviderType.find_by_codename('ec2') + CredentialDefinition.all.each do |cred| + if cred.provider_type != ec2 + if cred.name == 'username' + cred.update_attribute(:label, 'Username') + elsif cred.name == 'password' + cred.update_attribute(:label, 'Password') + end + else + if cred.name == 'username' + cred.update_attribute(:label, 'API Key') + elsif cred.name == 'password' + cred.update_attribute(:label, 'Secret') + end + end + end + end + + def self.transform_credential_definitions_back + ec2 = ProviderType.find_by_codename('ec2') + CredentialDefinition.all.each do |cred| + if cred.provider_type != ec2 + if cred.name == 'username' + cred.update_attribute(:label, 'API Key') + elsif cred.name == 'password' + cred.update_attribute(:label, 'Secret') + end + else + if cred.name == 'username' + cred.update_attribute(:label, 'Username') + elsif cred.name == 'password' + cred.update_attribute(:label, 'Password') + end + end + end + end + +end diff --git a/src/db/seeds.rb b/src/db/seeds.rb index cafcc79..69be3f4 100644 --- a/src/db/seeds.rb +++ b/src/db/seeds.rb @@ -126,15 +126,15 @@ end if CredentialDefinition.all.empty? ProviderType.all.each do |provider_type| unless provider_type.codename == 'ec2' - CredentialDefinition.create!(:name => 'username', :label => 'API Key', :input_type => 'text', :provider_type_id => provider_type.id) - CredentialDefinition.create!(:name => 'password', :label => 'Secret', :input_type => 'password', :provider_type_id => provider_type.id) + CredentialDefinition.create!(:name => 'username', :label => 'Username', :input_type => 'text', :provider_type_id => provider_type.id) + CredentialDefinition.create!(:name => 'password', :label => 'Password', :input_type => 'password', :provider_type_id => provider_type.id) end end
#for ec2 provider type ec2 = ProviderType.find_by_codename 'ec2' - CredentialDefinition.create!(:name => 'username', :label => 'Username', :input_type => 'text', :provider_type_id => ec2.id) - CredentialDefinition.create!(:name => 'password', :label => 'Password', :input_type => 'password', :provider_type_id => ec2.id) + CredentialDefinition.create!(:name => 'username', :label => 'API Key', :input_type => 'text', :provider_type_id => ec2.id) + CredentialDefinition.create!(:name => 'password', :label => 'Secret', :input_type => 'password', :provider_type_id => ec2.id) CredentialDefinition.create!(:name => 'account_id', :label => 'AWS Account ID', :input_type => 'text', :provider_type_id => ec2.id) CredentialDefinition.create!(:name => 'x509private', :label => 'EC2 x509 private key', :input_type => 'file', :provider_type_id => ec2.id) CredentialDefinition.create!(:name => 'x509public', :label => 'EC2 x509 public key', :input_type => 'file', :provider_type_id => ec2.id)
On 03/31/2011 09:44 AM, jzigmund@redhat.com wrote:
From: Jozef Zigmundjzigmund@redhat.com
...20110331152400_change_credential_definitions.rb | 48 ++++++++++++++++++++ src/db/seeds.rb | 8 ++-- 2 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 src/db/migrate/20110331152400_change_credential_definitions.rb
Ack.
aeolus-devel@lists.fedorahosted.org