Class: CloudFlock::Target::Servers::Profile
- Inherits:
-
Object
- Object
- CloudFlock::Target::Servers::Profile
- Defined in:
- lib/cloudflock/errstr.rb,
lib/cloudflock/target/servers/profile.rb
Constant Summary collapse
- NOT_SSH =
'SSH session expected.'
- SUPPORTED_DISTROS =
Public: List of linux distributions supported by CloudFlock
%w{Arch CentOS Debian SUSE Ubuntu RedHat Gentoo}
Instance Method Summary collapse
-
#[](key) ⇒ Object
Public: Simplify access to @info.
-
#build ⇒ Object
Public: Build the profile by calling all methods which begin with ‘determine_’.
-
#initialize(shell) ⇒ Profile
constructor
Public: Initialize the Profile object.
-
#keys ⇒ Object
Public: Allow access to the list of keys in @info.
-
#to_hash ⇒ Object
Public: Return server information and warnings as a Hash.
Constructor Details
#initialize(shell) ⇒ Profile
Public: Initialize the Profile object.
shell - An SSH object which is open to the host which will be profiled.
Raises TypeError if shell is not of type SSH.
15 16 17 18 19 20 21 22 23 |
# File 'lib/cloudflock/target/servers/profile.rb', line 15 def initialize(shell) unless shell.is_a?(CloudFlock::Remote::SSH) raise(TypeError, Errstr::NOT_SSH) end @shell = shell @warnings = [] @info = {} end |
Instance Method Details
#[](key) ⇒ Object
Public: Simplify access to @info.
key - Object to be used as the key in the @info Hash.
Returns a value stored in @info.
50 51 52 |
# File 'lib/cloudflock/target/servers/profile.rb', line 50 def [](key) @info[key] end |
#build ⇒ Object
Public: Build the profile by calling all methods which begin with ‘determine_’.
Returns nothing.
29 30 31 32 33 34 35 36 |
# File 'lib/cloudflock/target/servers/profile.rb', line 29 def build methods.select { |x| x =~ /^determine_/ }.each do |method| self.send(method) end methods.select { |x| x =~ /^warning_/ }.each do |method| self.send(method) end end |
#keys ⇒ Object
Public: Allow access to the list of keys in @info.
Returns an Array of keys in @info.
41 42 43 |
# File 'lib/cloudflock/target/servers/profile.rb', line 41 def keys @info.keys end |
#to_hash ⇒ Object
Public: Return server information and warnings as a Hash.
Returns a Hash.
57 58 59 |
# File 'lib/cloudflock/target/servers/profile.rb', line 57 def to_hash @info.merge({warnings: @warnings}) end |