Class: ClusterChef::Cloud::Base
- Defined in:
- lib/cluster_chef/cloud.rb
Overview
Right now only one cloud provider is implemented, so the separation between ‘cloud` and `cloud(:ec2)` is muddy.
The goal though is to allow
-
cloud with no predicate – definitions that apply to all cloud providers. If you only use one provider ever nothing stops you from always saying ‘cloud`.
-
Declarations irrelevant to other providers are acceptable and will be ignored
-
Declarations that are wrong in the context of other providers (a ‘public_ip` that is not available) will presumably cause a downstream error – it’s your responsibility to overlay with provider-correct values.
-
There are several declarations that could be sensibly abstracted, but are not. Rather than specifying ‘flavor ’m1.xlarge’‘, I could ask for :ram => 15, :cores => 4 or storage => 1500 and get the cheapest machine that met or exceeded each constraint – the default of `:price => :smallest` would get me a t1.micro on EC2, a 256MB on Rackspace. Availability zones could also plausibly be parameterized.
Instance Attribute Summary collapse
-
#owner ⇒ Object
Returns the value of attribute owner.
Instance Method Summary collapse
-
#bits ⇒ Object
The instance bitness, drawn from the compute flavor’s info.
-
#bootstrap_distro(val = nil) ⇒ Object
Distribution knife should target when bootstrapping an instance.
-
#defaults ⇒ Object
default values to apply where no value was set.
-
#image_id(val = nil) ⇒ Object
ID of the machine image to use.
-
#initialize(owner, *args) ⇒ Base
constructor
A new instance of Base.
-
#price ⇒ Object
The instance price, drawn from the compute flavor’s info.
-
#ssh_identity_dir(val = nil) ⇒ Object
Location of ssh private keys.
-
#ssh_identity_file(val = nil) ⇒ Object
SSH identity file used for knife ssh, knife boostrap and such.
-
#ssh_user(val = nil) ⇒ Object
The username to ssh with.
- #validation_key ⇒ Object
Methods inherited from DslObject
#configure, #die, #dump, has_keys, #reverse_merge!, #safely, #set, #step, #to_hash, #to_mash, #to_s, #ui, ui
Constructor Details
#initialize(owner, *args) ⇒ Base
Returns a new instance of Base.
54 55 56 57 |
# File 'lib/cluster_chef/cloud.rb', line 54 def initialize(owner, *args) self.owner = owner super(*args) end |
Instance Attribute Details
#owner ⇒ Object
Returns the value of attribute owner.
52 53 54 |
# File 'lib/cluster_chef/cloud.rb', line 52 def owner @owner end |
Instance Method Details
#bits ⇒ Object
The instance bitness, drawn from the compute flavor’s info
107 108 109 |
# File 'lib/cluster_chef/cloud.rb', line 107 def bits flavor_info[:bits] end |
#bootstrap_distro(val = nil) ⇒ Object
Distribution knife should target when bootstrapping an instance
93 94 95 |
# File 'lib/cluster_chef/cloud.rb', line 93 def bootstrap_distro(val=nil) from_setting_or_image_info :bootstrap_distro, val, "ubuntu10.04-gems" end |
#defaults ⇒ Object
default values to apply where no value was set
61 62 63 64 65 |
# File 'lib/cluster_chef/cloud.rb', line 61 def defaults reverse_merge!({ :image_name => 'natty', }) end |
#image_id(val = nil) ⇒ Object
ID of the machine image to use.
87 88 89 |
# File 'lib/cluster_chef/cloud.rb', line 87 def image_id(val=nil) from_setting_or_image_info :image_id, val end |
#price ⇒ Object
The instance price, drawn from the compute flavor’s info
102 103 104 |
# File 'lib/cluster_chef/cloud.rb', line 102 def price flavor_info[:price] end |
#ssh_identity_dir(val = nil) ⇒ Object
Location of ssh private keys
74 75 76 77 |
# File 'lib/cluster_chef/cloud.rb', line 74 def ssh_identity_dir(val=nil) set :ssh_identity_dir, File.(val) unless val.nil? @settings.include?(:ssh_identity_dir) ? @settings[:ssh_identity_dir] : Chef::Config.ec2_key_dir end |
#ssh_identity_file(val = nil) ⇒ Object
SSH identity file used for knife ssh, knife boostrap and such
80 81 82 83 |
# File 'lib/cluster_chef/cloud.rb', line 80 def ssh_identity_file(val=nil) set :ssh_identity_file, File.(val) unless val.nil? @settings.include?(:ssh_identity_file) ? @settings[:ssh_identity_file] : File.join(ssh_identity_dir, "#{keypair}.pem") end |
#ssh_user(val = nil) ⇒ Object
The username to ssh with.
69 70 71 |
# File 'lib/cluster_chef/cloud.rb', line 69 def ssh_user(val=nil) from_setting_or_image_info :ssh_user, val, 'root' end |
#validation_key ⇒ Object
97 98 99 |
# File 'lib/cluster_chef/cloud.rb', line 97 def validation_key IO.read(Chef::Config.validation_key) rescue '' end |