Class: PoolParty::Remote::Ec2RemoteInstance

Inherits:
RemoteInstance show all
Includes:
Dslify
Defined in:
lib/poolparty/net/remoter_bases/ec2/ec2_remote_instance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RemoteInstance

#dependency_resolver_command, #elapsed_runtime, hash_from_s, #hosts_file_listing_for, #load, #master?, #on_init, puppet_master_rerun_command, puppet_rerun_commad, puppet_runner_command, #puppet_runner_command, #responding?, #to_s, to_s, #valid?

Constructor Details

#initialize(opts = {}, prnt = Ec2.new) ⇒ Ec2RemoteInstance

A new instance will be created from the passed in hash.

This hash of passed in values will be converted to methods on this instance. The parent clouds describe_instances list will be searched for the first one matching any of this instance’s provided unique identifiers. If an instance is found, this instance’s properties will be set to the properties provided If the found instance has properties of the same key as the provided options, the found instance’s values will override the passed in options



14
15
16
17
18
19
20
# File 'lib/poolparty/net/remoter_bases/ec2/ec2_remote_instance.rb', line 14

def initialize(opts={}, prnt=Ec2.new)
  @uniquely_identifiable_by = [:ip, :name, :dns_name, :instance_id]
  @original_options = opts
  @my_cloud = prnt
  super(opts, prnt)
  find_myself(@uniquely_identifiable_by && opts.keys) if prnt.respond_to?(:describe_instances)
end

Instance Attribute Details

#found_atObject (readonly)

Returns the value of attribute found_at.



6
7
8
# File 'lib/poolparty/net/remoter_bases/ec2/ec2_remote_instance.rb', line 6

def found_at
  @found_at
end

#my_cloudObject (readonly)

Returns the value of attribute my_cloud.



6
7
8
# File 'lib/poolparty/net/remoter_bases/ec2/ec2_remote_instance.rb', line 6

def my_cloud
  @my_cloud
end

#uniquely_identifiable_byObject (readonly)

Returns the value of attribute uniquely_identifiable_by.



6
7
8
# File 'lib/poolparty/net/remoter_bases/ec2/ec2_remote_instance.rb', line 6

def uniquely_identifiable_by
  @uniquely_identifiable_by
end

Instance Method Details

#find_myself(unique_identifiers = @original_options.keys) ⇒ Object

Search the clouds describe_instances list for the first match on one of this nodes unique identifiers



23
24
25
26
27
28
29
30
31
32
# File 'lib/poolparty/net/remoter_bases/ec2/ec2_remote_instance.rb', line 23

def find_myself(unique_identifiers = @original_options.keys)
  description_hash = @my_cloud.describe_instances.detect do|node|
    unique_identifiers.detect{|identifier_key| node[identifier_key] == options[identifier_key]
      }
  end
  return nil if description_hash.blank?
  @found_at = Time.now
  self.set_vars_from_options(description_hash)
  self
end

#pending?Boolean

Is this instance pending?

Returns:

  • (Boolean)


39
40
41
# File 'lib/poolparty/net/remoter_bases/ec2/ec2_remote_instance.rb', line 39

def pending?
  !(status =~ /pending/).nil?
end

#running?Boolean

Is this instance running?

Returns:

  • (Boolean)


35
36
37
# File 'lib/poolparty/net/remoter_bases/ec2/ec2_remote_instance.rb', line 35

def running?
  !(status =~ /running/).nil?
end

#terminated?Boolean

Has this instance been terminated?

Returns:

  • (Boolean)


47
48
49
# File 'lib/poolparty/net/remoter_bases/ec2/ec2_remote_instance.rb', line 47

def terminated?
  !(status =~ /terminated/).nil?
end

#terminating?Boolean

Is this instance terminating?

Returns:

  • (Boolean)


43
44
45
# File 'lib/poolparty/net/remoter_bases/ec2/ec2_remote_instance.rb', line 43

def terminating?
  !(status =~ /shutting/).nil?
end