Class: Pec::Handler::UserData::Nic::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/pec/handler/user_data/nic/base.rb

Direct Known Subclasses

Rhel, Ubuntu

Constant Summary collapse

NAME =
0
CONFIG =
1

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.os_typeObject

Returns the value of attribute os_type.



6
7
8
# File 'lib/pec/handler/user_data/nic/base.rb', line 6

def os_type
  @os_type
end

Class Method Details

.default_path(port) ⇒ Object



30
31
32
# File 'lib/pec/handler/user_data/nic/base.rb', line 30

def default_path(port)
  raise "undfined method default_path"
end

.gen_user_data(networks, ports) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/pec/handler/user_data/nic/base.rb', line 7

def gen_user_data(networks, ports)
  networks.map do |network|
    port = ports.find {|p|p.name == network[NAME]}
    path = network[CONFIG]['path'] || default_path(port)
    {
      'content' => ifcfg_config(network, port),
      'owner' => "root:root",
      'path' => path,
      'permissions' => "0644"
    }
  end
end

.ifcfg_config(network, port) ⇒ Object



34
35
36
# File 'lib/pec/handler/user_data/nic/base.rb', line 34

def ifcfg_config(network, port)
  raise "undfined method ifcfg_config"
end

.safe_merge(base, network) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/pec/handler/user_data/nic/base.rb', line 20

def safe_merge(base, network)
  # delete option column
  mask_column = Pec::Handler::Networks.constants.map {|c| Object.const_get("Pec::Handler::Networks::#{c}").kind }
  mask_config = network[CONFIG].reject {|k,v| mask_column.include?(k)}

  base.merge(
    mask_config
  )
end