Class: Pec::Configure::Host
- Inherits:
-
Object
- Object
- Pec::Configure::Host
- Defined in:
- lib/pec/configure/host.rb
Instance Attribute Summary collapse
-
#flavor ⇒ Object
readonly
Returns the value of attribute flavor.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#networks ⇒ Object
readonly
Returns the value of attribute networks.
-
#security_group ⇒ Object
readonly
Returns the value of attribute security_group.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
-
#tenant ⇒ Object
readonly
Returns the value of attribute tenant.
-
#user_data ⇒ Object
readonly
Returns the value of attribute user_data.
Class Method Summary collapse
Instance Method Summary collapse
- #append_network(network) ⇒ Object
-
#initialize(config) ⇒ Host
constructor
A new instance of Host.
Constructor Details
#initialize(config) ⇒ Host
Returns a new instance of Host.
5 6 7 8 9 10 11 12 13 |
# File 'lib/pec/configure/host.rb', line 5 def initialize(config) @name = config[0]; @image = config[1]["image"]; @flavor = config[1]["flavor"]; @security_group = config[1]["security_group"]; @user_data = config[1]["user_data"]; @templates = config[1]["templates"] @tenant = config[1]["tenant"] end |
Instance Attribute Details
#flavor ⇒ Object (readonly)
Returns the value of attribute flavor.
4 5 6 |
# File 'lib/pec/configure/host.rb', line 4 def flavor @flavor end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
4 5 6 |
# File 'lib/pec/configure/host.rb', line 4 def image @image end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/pec/configure/host.rb', line 4 def name @name end |
#networks ⇒ Object (readonly)
Returns the value of attribute networks.
4 5 6 |
# File 'lib/pec/configure/host.rb', line 4 def networks @networks end |
#security_group ⇒ Object (readonly)
Returns the value of attribute security_group.
4 5 6 |
# File 'lib/pec/configure/host.rb', line 4 def security_group @security_group end |
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
4 5 6 |
# File 'lib/pec/configure/host.rb', line 4 def templates @templates end |
#tenant ⇒ Object (readonly)
Returns the value of attribute tenant.
4 5 6 |
# File 'lib/pec/configure/host.rb', line 4 def tenant @tenant end |
#user_data ⇒ Object (readonly)
Returns the value of attribute user_data.
4 5 6 |
# File 'lib/pec/configure/host.rb', line 4 def user_data @user_data end |
Class Method Details
.check_require_key(config) ⇒ Object
30 31 32 33 34 |
# File 'lib/pec/configure/host.rb', line 30 def check_require_key(config) err = %w(image flavor tenant).find {|r| !config[1].key?(r) || config[1][r].nil? } raise(Pec::Errors::Host,"skip! #{config[0]}: #{err} is required!") unless err.nil? true end |
.load(config) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/pec/configure/host.rb', line 21 def load(config) host = self.new(config) if check_require_key(config) config[1]["networks"].each do |net| net_config = Pec::Configure::Ethernet.load(config[0], net) host.append_network(net_config) if net_config end if host && config[1]["networks"] host end |
Instance Method Details
#append_network(network) ⇒ Object
15 16 17 18 |
# File 'lib/pec/configure/host.rb', line 15 def append_network(network) @networks ||= [] @networks << network end |