Class: Ironfan::Provider::Ec2

Inherits:
IaasProvider show all
Defined in:
lib/ironfan/headers.rb,
lib/ironfan/provider/ec2.rb,
lib/ironfan/provider/ec2/keypair.rb,
lib/ironfan/provider/ec2/machine.rb,
lib/ironfan/provider/ec2/ebs_volume.rb,
lib/ironfan/provider/ec2/elastic_ip.rb,
lib/ironfan/provider/ec2/security_group.rb,
lib/ironfan/provider/ec2/placement_group.rb,
lib/ironfan/provider/ec2/elastic_load_balancer.rb,
lib/ironfan/provider/ec2/iam_server_certificate.rb

Defined Under Namespace

Classes: EbsVolume, ElasticIp, ElasticLoadBalancer, IamServerCertificate, Keypair, Machine, PlacementGroup, SecurityGroup

Class Method Summary collapse

Methods inherited from IaasProvider

#ensure_prerequisites!, machine_class, #save!

Methods inherited from Ironfan::Provider

aggregate!, forget!, load, prepare!, receive, #resources, validate

Methods inherited from Builder

ui, #ui

Class Method Details

.applicable(computer) ⇒ Object


47
48
49
# File 'lib/ironfan/provider/ec2.rb', line 47

def self.applicable(computer)
  computer.server and computer.server.clouds.include?(:ec2)
end

.aws_account_idObject


28
29
30
# File 'lib/ironfan/provider/ec2.rb', line 28

def self.()
  Chef::Config[:knife][:aws_account_id]
end

.connectionObject

Utility functions


14
15
16
# File 'lib/ironfan/provider/ec2.rb', line 14

def self.connection
  @@connection ||= Fog::Compute.new(self.aws_credentials.merge({ :provider => 'AWS' }))
end

.elbObject


18
19
20
# File 'lib/ironfan/provider/ec2.rb', line 18

def self.elb
  @@elb ||= Fog::AWS::ELB.new(self.aws_credentials)
end

.ensure_tags(tags, fog) ⇒ Object

Ensure that a fog object (machine, volume, etc.) has the proper tags on it


33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ironfan/provider/ec2.rb', line 33

def self.ensure_tags(tags,fog)
  tags.delete_if {|k, v| fog.tags[k] == v.to_s  rescue false }
  return if tags.empty?

  Ironfan.step(fog.name,"tagging with #{tags.inspect}", :green)
  tags.each do |k, v|
    Chef::Log.debug( "tagging #{fog.name} with #{k} = #{v}" )
    Ironfan.safely do
      config = {:key => k, :value => v.to_s, :resource_id => fog.id }
      connection.tags.create(config)
    end
  end
end

.iamObject


22
23
24
25
26
# File 'lib/ironfan/provider/ec2.rb', line 22

def self.iam
  credentials = self.aws_credentials
  credentials.delete(:region)
  @@iam ||= Fog::AWS::IAM.new(credentials)
end

.resourcesObject


7
8
9
# File 'lib/ironfan/provider/ec2.rb', line 7

def self.resources
  [ Machine, ElasticIp, EbsVolume, Keypair, SecurityGroup, IamServerCertificate, ElasticLoadBalancer ]
end