Class: Ironfan::Provider::OpenStack

Inherits:
IaasProvider show all
Defined in:
lib/ironfan/headers.rb,
lib/ironfan/provider/openstack.rb,
lib/ironfan/provider/openstack/keypair.rb,
lib/ironfan/provider/openstack/machine.rb,
lib/ironfan/provider/openstack/elastic_ip.rb,
lib/ironfan/provider/openstack/security_group.rb

Defined Under Namespace

Classes: ElasticIp, Keypair, Machine, 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


51
52
53
# File 'lib/ironfan/provider/openstack.rb', line 51

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

.connectionObject

Utility functions


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

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

.ensure_tags(tags, fog) ⇒ Object

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


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ironfan/provider/openstack.rb', line 35

def self.ensure_tags(tags,fog)
  # openstack does not have tags.

  #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

.flavor_hashObject

Returns a hash that maps flavor names to flavors


22
23
24
# File 'lib/ironfan/provider/openstack.rb', line 22

def self.flavor_hash
  @@flavors ||= self.connection.flavors.inject({}){|h,f| h[f.name]=f; h }
end

.flavor_id_hashObject

Returns a hash that maps flavor ids to flavors


29
30
31
# File 'lib/ironfan/provider/openstack.rb', line 29

def self.flavor_id_hash
  @@flavor_ids ||= self.connection.flavors.inject({}){|h,f| h[f.id]=f; h }
end

.resourcesObject


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

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