Class: Rubber::Configuration::InstanceItem
- Inherits:
-
Object
- Object
- Rubber::Configuration::InstanceItem
- Defined in:
- lib/rubber/instance.rb
Overview
The configuration for a single instance
Constant Summary collapse
- UBUNTU_OS_VERSION_CMD =
'lsb_release -sr'.freeze
- VARIABLES_TO_OMIT_IN_SERIALIZATION =
[ '@capistrano', '@os_version', '@subnet_id', '@vpc_id', '@vpc_cidr' ]
Instance Attribute Summary collapse
-
#capistrano ⇒ Object
Returns the value of attribute capistrano.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#external_host ⇒ Object
Returns the value of attribute external_host.
-
#external_ip ⇒ Object
Returns the value of attribute external_ip.
-
#gateway ⇒ Object
Returns the value of attribute gateway.
-
#image_id ⇒ Object
readonly
Returns the value of attribute image_id.
-
#image_type ⇒ Object
readonly
Returns the value of attribute image_type.
-
#instance_id ⇒ Object
readonly
Returns the value of attribute instance_id.
-
#internal_host ⇒ Object
Returns the value of attribute internal_host.
-
#internal_ip ⇒ Object
Returns the value of attribute internal_ip.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#network ⇒ Object
more generic term for vpc_alias.
-
#partitions ⇒ Object
Returns the value of attribute partitions.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#provider ⇒ Object
Returns the value of attribute provider.
-
#roles ⇒ Object
Returns the value of attribute roles.
-
#root_device_type ⇒ Object
Returns the value of attribute root_device_type.
-
#security_groups ⇒ Object
readonly
Returns the value of attribute security_groups.
-
#spot_instance_request_id ⇒ Object
Returns the value of attribute spot_instance_request_id.
-
#static_ip ⇒ Object
Returns the value of attribute static_ip.
-
#subnet_id ⇒ Object
Returns the value of attribute subnet_id.
-
#volumes ⇒ Object
Returns the value of attribute volumes.
-
#vpc_cidr ⇒ Object
Returns the value of attribute vpc_cidr.
-
#vpc_id ⇒ Object
Returns the value of attribute vpc_id.
-
#zone ⇒ Object
Returns the value of attribute zone.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(rhs) ⇒ Object
- #encode_with(coder) ⇒ Object
- #full_name ⇒ Object
-
#initialize(name, domain, roles, instance_id, image_type, image_id, security_group_list = []) ⇒ InstanceItem
constructor
A new instance of InstanceItem.
- #linux? ⇒ Boolean
- #mac? ⇒ Boolean
- #os_version ⇒ Object
- #role_names ⇒ Object
- #to_hash ⇒ Object
- #windows? ⇒ Boolean
Constructor Details
#initialize(name, domain, roles, instance_id, image_type, image_id, security_group_list = []) ⇒ InstanceItem
Returns a new instance of InstanceItem.
218 219 220 221 222 223 224 225 226 227 |
# File 'lib/rubber/instance.rb', line 218 def initialize(name, domain, roles, instance_id, image_type, image_id, security_group_list=[]) @name = name @domain = domain @roles = roles @instance_id = instance_id @image_type = image_type @image_id = image_id @security_groups = security_group_list @os_version = nil end |
Instance Attribute Details
#capistrano ⇒ Object
Returns the value of attribute capistrano.
211 212 213 |
# File 'lib/rubber/instance.rb', line 211 def capistrano @capistrano end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
204 205 206 |
# File 'lib/rubber/instance.rb', line 204 def domain @domain end |
#external_host ⇒ Object
Returns the value of attribute external_host.
206 207 208 |
# File 'lib/rubber/instance.rb', line 206 def external_host @external_host end |
#external_ip ⇒ Object
Returns the value of attribute external_ip.
206 207 208 |
# File 'lib/rubber/instance.rb', line 206 def external_ip @external_ip end |
#gateway ⇒ Object
Returns the value of attribute gateway.
216 217 218 |
# File 'lib/rubber/instance.rb', line 216 def gateway @gateway end |
#image_id ⇒ Object (readonly)
Returns the value of attribute image_id.
204 205 206 |
# File 'lib/rubber/instance.rb', line 204 def image_id @image_id end |
#image_type ⇒ Object (readonly)
Returns the value of attribute image_type.
204 205 206 |
# File 'lib/rubber/instance.rb', line 204 def image_type @image_type end |
#instance_id ⇒ Object (readonly)
Returns the value of attribute instance_id.
204 205 206 |
# File 'lib/rubber/instance.rb', line 204 def instance_id @instance_id end |
#internal_host ⇒ Object
Returns the value of attribute internal_host.
207 208 209 |
# File 'lib/rubber/instance.rb', line 207 def internal_host @internal_host end |
#internal_ip ⇒ Object
Returns the value of attribute internal_ip.
207 208 209 |
# File 'lib/rubber/instance.rb', line 207 def internal_ip @internal_ip end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
204 205 206 |
# File 'lib/rubber/instance.rb', line 204 def name @name end |
#network ⇒ Object
more generic term for vpc_alias
213 214 215 |
# File 'lib/rubber/instance.rb', line 213 def network @network end |
#partitions ⇒ Object
Returns the value of attribute partitions.
208 209 210 |
# File 'lib/rubber/instance.rb', line 208 def partitions @partitions end |
#platform ⇒ Object
Returns the value of attribute platform.
210 211 212 |
# File 'lib/rubber/instance.rb', line 210 def platform @platform end |
#provider ⇒ Object
Returns the value of attribute provider.
210 211 212 |
# File 'lib/rubber/instance.rb', line 210 def provider @provider end |
#roles ⇒ Object
Returns the value of attribute roles.
205 206 207 |
# File 'lib/rubber/instance.rb', line 205 def roles @roles end |
#root_device_type ⇒ Object
Returns the value of attribute root_device_type.
208 209 210 |
# File 'lib/rubber/instance.rb', line 208 def root_device_type @root_device_type end |
#security_groups ⇒ Object (readonly)
Returns the value of attribute security_groups.
204 205 206 |
# File 'lib/rubber/instance.rb', line 204 def security_groups @security_groups end |
#spot_instance_request_id ⇒ Object
Returns the value of attribute spot_instance_request_id.
209 210 211 |
# File 'lib/rubber/instance.rb', line 209 def spot_instance_request_id @spot_instance_request_id end |
#static_ip ⇒ Object
Returns the value of attribute static_ip.
208 209 210 |
# File 'lib/rubber/instance.rb', line 208 def static_ip @static_ip end |
#subnet_id ⇒ Object
Returns the value of attribute subnet_id.
215 216 217 |
# File 'lib/rubber/instance.rb', line 215 def subnet_id @subnet_id end |
#volumes ⇒ Object
Returns the value of attribute volumes.
208 209 210 |
# File 'lib/rubber/instance.rb', line 208 def volumes @volumes end |
#vpc_cidr ⇒ Object
Returns the value of attribute vpc_cidr.
214 215 216 |
# File 'lib/rubber/instance.rb', line 214 def vpc_cidr @vpc_cidr end |
#vpc_id ⇒ Object
Returns the value of attribute vpc_id.
212 213 214 |
# File 'lib/rubber/instance.rb', line 212 def vpc_id @vpc_id end |
#zone ⇒ Object
Returns the value of attribute zone.
205 206 207 |
# File 'lib/rubber/instance.rb', line 205 def zone @zone end |
Class Method Details
Instance Method Details
#<=>(rhs) ⇒ Object
252 253 254 |
# File 'lib/rubber/instance.rb', line 252 def <=>(rhs) name <=> rhs.name end |
#encode_with(coder) ⇒ Object
304 305 306 307 308 309 310 311 |
# File 'lib/rubber/instance.rb', line 304 def encode_with(coder) vars = instance_variables.map { |x| x.to_s } vars = vars - VARIABLES_TO_OMIT_IN_SERIALIZATION vars.each do |var| coder[var.gsub('@', '')] = eval(var) end end |
#full_name ⇒ Object
256 257 258 |
# File 'lib/rubber/instance.rb', line 256 def full_name "#{@name}.#{@domain}" end |
#linux? ⇒ Boolean
274 275 276 |
# File 'lib/rubber/instance.rb', line 274 def linux? platform == Rubber::Platforms::LINUX end |
#mac? ⇒ Boolean
278 279 280 |
# File 'lib/rubber/instance.rb', line 278 def mac? platform == Rubber::Platforms::MAC end |
#os_version ⇒ Object
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/rubber/instance.rb', line 286 def os_version @os_version ||= begin os_version_cmd = Rubber.config.os_version_cmd || UBUNTU_OS_VERSION_CMD if capistrano @os_version = capistrano.capture(os_version_cmd, :host => self.full_name).chomp else # If we can't SSH to the machine, we may be able to execute the command locally if this # instance item happens to refer to the same machine we're executing on. if Socket::gethostname == self.full_name @os_version = `#{os_version_cmd}`.chomp else raise "Unable to get os_version for #{self.full_name}" end end end end |
#role_names ⇒ Object
260 261 262 |
# File 'lib/rubber/instance.rb', line 260 def role_names roles.collect {|r| r.name} end |
#to_hash ⇒ Object
239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/rubber/instance.rb', line 239 def to_hash hash = {} instance_variables.each do |iv| next if VARIABLES_TO_OMIT_IN_SERIALIZATION.include?(iv.to_s) name = iv.to_s.gsub(/^@/, '') value = instance_variable_get(iv) value = value.collect {|r| r.to_s } if name == 'roles' hash[name] = value end return hash end |