Module: PoolParty::Remote::RemoterBase

Included in:
Cloud::Cloud
Defined in:
lib/poolparty/net/remoter_base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(other) ⇒ Object



91
92
93
# File 'lib/poolparty/net/remoter_base.rb', line 91

def self.included(other)
  PoolParty.register_remote_base(self.class.to_s.downcase.to_sym)
end

Instance Method Details

#create_keypair ⇒ Object

Helpers



86
87
# File 'lib/poolparty/net/remoter_base.rb', line 86

def create_keypair
end

#custom_configure_tasks_for(a = nil) ⇒ Object

Custom configure tasks Allows the remoter bases to attach their own custom configuration tasks to the configuration process



108
109
110
# File 'lib/poolparty/net/remoter_base.rb', line 108

def custom_configure_tasks_for(a=nil)
  []
end

#custom_install_tasks_for(a = nil) ⇒ Object

Custom installation tasks Allow the remoter bases to attach their own tasks on the installation process



102
103
104
# File 'lib/poolparty/net/remoter_base.rb', line 102

def custom_install_tasks_for(a=nil)
  []
end

#get_instance_by_number(i = 0, list = remote_instances_list) ⇒ Object

Get instance by number



65
66
67
68
# File 'lib/poolparty/net/remoter_base.rb', line 65

def get_instance_by_number(i=0, list = remote_instances_list)
  name = (i.zero? ? "master" : "node#{i}")
  list.select {|i| i.name == name }.first
end

#list_of_instances(keyp = nil) ⇒ Object

List the instances for the current key pair, regardless of their states If no keypair is passed, select them all



74
75
76
77
# File 'lib/poolparty/net/remoter_base.rb', line 74

def list_of_instances(keyp=nil)
  key = keyp ? keyp : keypair
  describe_instances.select {|a| key ? a[:keypair] == key : true }
end

#list_of_nonterminated_instances(list = remote_instances_list) ⇒ Object

list all the nonterminated instances



61
62
63
# File 'lib/poolparty/net/remoter_base.rb', line 61

def list_of_nonterminated_instances(list = remote_instances_list)
  list.reject {|i| i.terminating? || i.terminated? }
end

#list_of_pending_instances(list = list_of_nonterminated_instances) ⇒ Object

Get a list of the pending instances



49
50
51
# File 'lib/poolparty/net/remoter_base.rb', line 49

def list_of_pending_instances(list = list_of_nonterminated_instances)
  list.select {|a| a.pending? }
end

#list_of_running_instances(list = list_of_nonterminated_instances) ⇒ Object

The following methods are inherent on the RemoterBase If you need to overwrite these methods, do so with caution Listing methods



45
46
47
# File 'lib/poolparty/net/remoter_base.rb', line 45

def list_of_running_instances(list = list_of_nonterminated_instances)
  list.select {|a| a.running? }
end

#list_of_terminating_instances(list = remote_instances_list) ⇒ Object

list of shutting down instances



53
54
55
# File 'lib/poolparty/net/remoter_base.rb', line 53

def list_of_terminating_instances(list = remote_instances_list)
  list.reject {|i| true if !i.terminating? }
end

#loaded_remoter_base ⇒ Object

Callback after loaded



96
97
# File 'lib/poolparty/net/remoter_base.rb', line 96

def loaded_remoter_base        
end

#master ⇒ Object

Instances Get the master from the cloud



80
81
82
83
84
# File 'lib/poolparty/net/remoter_base.rb', line 80

def master
  # remote_instances_list.select {|a| a.master }.first
  @list = list_from_remote
  @list.reject {|a| a unless a.name =~ /master/ }.first if @list.class != String
end

#nonmaster_nonterminated_instances(list = remote_instances_list) ⇒ Object

Get the instances that are non-master instances



57
58
59
# File 'lib/poolparty/net/remoter_base.rb', line 57

def nonmaster_nonterminated_instances(list = remote_instances_list)
  list_of_nonterminated_instances.reject {|i| i.master? }
end

#remote_instances_list ⇒ Object



69
70
71
# File 'lib/poolparty/net/remoter_base.rb', line 69

def remote_instances_list
  list_of_instances.map {|i| PoolParty::Remote::RemoteInstance.new(i, self) }
end

#reset! ⇒ Object

Reset the cache of descriptions



89
90
# File 'lib/poolparty/net/remoter_base.rb', line 89

def reset!
end