fluke/devops-service/providers/ec2_accounts_factory.rb

38 lines
1.0 KiB
Ruby
Raw Normal View History

2015-10-26 17:14:48 +03:00
require_relative "accounts_factory"
module Provider
class Ec2AccountsFactory < AccountsFactory
def init config
@connections = {}
2015-11-02 17:33:25 +03:00
accounts.each do |account|
2015-10-28 17:27:02 +03:00
create_connection_from_account(config, account)
2015-10-26 17:14:48 +03:00
puts "\tFound ec2 account '#{account.account_name}'"
end
2015-11-02 11:42:20 +03:00
ProviderFactory.add_provider Ec2::PROVIDER unless @connections.empty?
2015-10-26 17:14:48 +03:00
end
2015-11-02 17:33:25 +03:00
def provider_name
Ec2::PROVIDER
end
2015-10-28 17:27:02 +03:00
def create_connection_from_account config, account
options = {
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
2015-11-02 17:33:25 +03:00
def create_account hash
Devops::Model::Ec2ProviderAccount.new(hash)
end
2015-10-26 17:14:48 +03:00
end
end