Class: CloudProviders::CloudProvider
- Includes:
- Callbacks, Dslify
- Defined in:
- lib/cloud_providers/cloud_provider.rb
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
All CloudProviders are added to the CloudProviders.all array.
Instance Method Summary collapse
- #after_compile(cld) ⇒ Object
- #before_compile(cld) ⇒ Object
-
#describe_instance(hash_of_criteria_to_select_instance_against) ⇒ Object
Describe an instance’s status.
-
#describe_instances(o = {}) ⇒ Object
Get instances The instances must return an object responding to each Each yielded object must respond to [:status].
-
#initialize(opts = {}, &block) ⇒ CloudProvider
constructor
A new instance of CloudProvider.
-
#keypair(n = keypair_name) ⇒ Object
Returns an instance of Keypair You can pass either a filename which will be searched for in ~/.ec2/ and ~/.ssh/ or you can pass a full filepath.
- #keypair=(n) ⇒ Object
-
#nodes(hsh = {}) ⇒ Object
Nodes returns nodes from the describe_instances array These can be selected on by passing a hash.
-
#run_instance(o = {}) ⇒ Object
Launch a new instance.
-
#terminate_instance!(o = {}) ⇒ Object
Terminate an instance by id Required params: instance_id or instance_ids.
Methods included from Callbacks
Constructor Details
#initialize(opts = {}, &block) ⇒ CloudProvider
Returns a new instance of CloudProvider.
22 23 24 25 |
# File 'lib/cloud_providers/cloud_provider.rb', line 22 def initialize(opts={}, &block) (opts) instance_eval(&block) if block end |
Class Method Details
.inherited(subclass) ⇒ Object
All CloudProviders are added to the CloudProviders.all array
16 17 18 19 20 |
# File 'lib/cloud_providers/cloud_provider.rb', line 16 def self.inherited(subclass) unless CloudProviders.all.include?(subclass) CloudProviders.all << subclass end end |
Instance Method Details
#after_compile(cld) ⇒ Object
87 88 |
# File 'lib/cloud_providers/cloud_provider.rb', line 87 def after_compile(cld) end |
#before_compile(cld) ⇒ Object
84 85 |
# File 'lib/cloud_providers/cloud_provider.rb', line 84 def before_compile(cld) end |
#describe_instance(hash_of_criteria_to_select_instance_against) ⇒ Object
Describe an instance’s status. Should return a hash like object Required keys are: :image_id :keypair_name :instance_id :status
51 52 53 |
# File 'lib/cloud_providers/cloud_provider.rb', line 51 def describe_instance(hash_of_criteria_to_select_instance_against) raise StandardError.new("method_not_defined :describe_instance") end |
#describe_instances(o = {}) ⇒ Object
Get instances The instances must return an object responding to each Each yielded object must respond to [:status]
58 59 60 |
# File 'lib/cloud_providers/cloud_provider.rb', line 58 def describe_instances(o={}) raise StandardError.new("method_not_defined :describe_instances") end |
#keypair(n = keypair_name) ⇒ Object
Returns an instance of Keypair You can pass either a filename which will be searched for in ~/.ec2/ and ~/.ssh/ or you can pass a full filepath
67 68 69 70 71 |
# File 'lib/cloud_providers/cloud_provider.rb', line 67 def keypair(n=keypair_name) @keypair ||= Keypair.new(n) keypair_name @keypair.basename @keypair end |
#keypair=(n) ⇒ Object
72 73 74 |
# File 'lib/cloud_providers/cloud_provider.rb', line 72 def keypair=(n) @keypair = n end |
#nodes(hsh = {}) ⇒ Object
Nodes returns nodes from the describe_instances array These can be selected on by passing a hash
79 80 81 82 |
# File 'lib/cloud_providers/cloud_provider.rb', line 79 def nodes(hsh={}) results = describe_instances(:status=>'running').select_with_hash({:keypair_name => keypair.basename}) results.select_with_hash(hsh) end |
#run_instance(o = {}) ⇒ Object
Launch a new instance
34 35 36 |
# File 'lib/cloud_providers/cloud_provider.rb', line 34 def run_instance(o={}) raise StandardError.new("method_not_defined :launch_new_instance") end |
#terminate_instance!(o = {}) ⇒ Object
Terminate an instance by id Required params:
instance_id or instance_ids
41 42 43 |
# File 'lib/cloud_providers/cloud_provider.rb', line 41 def terminate_instance!(o={}) raise StandardError.new("method_not_defined :terminate_instance!") end |