Module: PoolParty::CloudResourcer

Instance Method Summary collapse

Instance Method Details

#full_keypair_path ⇒ Object



14
15
16
17
18
19
20
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 14

def full_keypair_path
  unless keypair_path
    raise RuntimeException.new("Keypair cannot be found")        
  else
    ::File.expand_path(keypair_path)
  end
end

#instances(arg) ⇒ Object

Set instances with a range



7
8
9
10
11
12
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 7

def instances(arg)
  if arg.is_a?(Range)
    minimum_instances arg.first
    maximum_instances arg.last
  end
end

#keypair_path ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 22

def keypair_path
  keypair_paths.each do |path|
    possible_keypair_basenames.each do |base|
      full_path = ::File.join( File.expand_path(path), "#{base}#{keypair}")
      return full_path if ::File.exists?(full_path)
    end
  end
  return nil
end

#keypair_paths ⇒ Object



43
44
45
46
47
48
49
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 43

def keypair_paths
  [
    Base.base_keypair_path,
    Base.base_config_directory,
    Base.remote_storage_path
  ]
end

#new_keypair_path ⇒ Object



32
33
34
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 32

def new_keypair_path
  ::File.join( keypair_paths.first, "#{possible_keypair_basenames.first}#{keypair}" )
end

#number_of_resources ⇒ Object



60
61
62
63
64
65
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 60

def number_of_resources
  arr = resources.map do |n, r|
    r.size
  end
  resources.map {|n,r| r.size}.inject(0){|sum,i| sum+=i}
end

#parent ⇒ Object



67
68
69
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 67

def parent
  @parent ||= nil
end

#possible_keypair_basenames ⇒ Object



36
37
38
39
40
41
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 36

def possible_keypair_basenames
  [
    "id_rsa-",
    ""
  ]
end

#set_parent(pare) ⇒ Object

Set the parent on the resource



52
53
54
55
56
57
58
# File 'lib/poolparty/modules/cloud_resourcer.rb', line 52

def set_parent(pare)
  @parent = pare
  # Add self as a service on the parent
  pare.add_service(self) if pare.respond_to?(:add_service)
  # Take the options of the parents
  configure(pare.options) if pare.respond_to?(:options)
end