Class: CloudProviders::CloudProvider

Inherits:
Object
  • Object
show all
Includes:
Dslify
Defined in:
lib/cloud_providers/cloud_provider.rb

Direct Known Subclasses

Base, Ec2, Ec2Helper

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, init_opts = {}, &block) ⇒ CloudProvider

Returns a new instance of CloudProvider.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cloud_providers/cloud_provider.rb', line 16

def initialize(name, init_opts={}, &block)
  @name = name
  if name.is_a?(Hash) && init_opts.empty?
    @init_opts = name
  else
    @init_opts = init_opts
  end
  set_vars_from_options(init_opts)
  instance_eval &block if block
  after_initialized
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *a, &block) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/cloud_providers/cloud_provider.rb', line 46

def method_missing(m,*a,&block)
  if cloud && cloud.respond_to?(m)
    cloud.send(m,*a,&block)
  else
    super
  end
end

Instance Attribute Details

#init_optsObject (readonly)

Returns the value of attribute init_opts.



14
15
16
# File 'lib/cloud_providers/cloud_provider.rb', line 14

def init_opts
  @init_opts
end

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/cloud_providers/cloud_provider.rb', line 14

def name
  @name
end

Class Method Details

.default_keypair_pathObject



39
40
41
# File 'lib/cloud_providers/cloud_provider.rb', line 39

def self.default_keypair_path
  ENV["EC2_CONFIG_DIR"] || "#{ENV["HOME"]}/.ssh"
end

Instance Method Details

#after_initializedObject



28
29
# File 'lib/cloud_providers/cloud_provider.rb', line 28

def after_initialized
end

#bootstrap_nodes!Object



43
44
# File 'lib/cloud_providers/cloud_provider.rb', line 43

def bootstrap_nodes!
end

#default_keypair_pathObject



35
36
37
# File 'lib/cloud_providers/cloud_provider.rb', line 35

def default_keypair_path
  self.class.default_keypair_path
end

#runObject



31
32
33
# File 'lib/cloud_providers/cloud_provider.rb', line 31

def run
  warn "#{self.class} does not implement run. Something is wrong"
end