Class: Pec::Configure::Host

Inherits:
Object
  • Object
show all
Defined in:
lib/pec/configure/host.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#flavorObject (readonly)

Returns the value of attribute flavor.



4
5
6
# File 'lib/pec/configure/host.rb', line 4

def flavor
  @flavor
end

#imageObject (readonly)

Returns the value of attribute image.



4
5
6
# File 'lib/pec/configure/host.rb', line 4

def image
  @image
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/pec/configure/host.rb', line 4

def name
  @name
end

#networksObject (readonly)

Returns the value of attribute networks.



4
5
6
# File 'lib/pec/configure/host.rb', line 4

def networks
  @networks
end

#security_groupObject (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

#templatesObject (readonly)

Returns the value of attribute templates.



4
5
6
# File 'lib/pec/configure/host.rb', line 4

def templates
  @templates
end

#tenantObject (readonly)

Returns the value of attribute tenant.



4
5
6
# File 'lib/pec/configure/host.rb', line 4

def tenant
  @tenant
end

#user_dataObject (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

Raises:



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