fluke/devops-service/providers/ec2_accounts_factory.rb
2015-10-28 17:27:02 +03:00

30 lines
922 B
Ruby

require_relative "accounts_factory"
module Provider
class Ec2AccountsFactory < AccountsFactory
def init config
@connections = {}
Devops::Db.connector.provider_accounts(Ec2::PROVIDER).each do |account|
create_connection_from_account(config, account)
puts "\tFound ec2 account '#{account.account_name}'"
end
end
def create_connection_from_account config, account
options = {
aws_certificate: account.certificate,
aws_ssh_key: account.ssh_key,
aws_access_key_id: account.access_key_id,
aws_secret_access_key: account.secret_access_key,
aws_availability_zone: account.availability_zone,
aws_proxy: config[:aws_proxy],
aws_no_proxy: config[:aws_no_proxy],
aws_integration_run_list: config[:aws_integration_run_list]
}
add_connection(account.account_name, Ec2.new(options))
end
end
end