class PackerFiles::Core::Network

Define the Network class that can handle Network specified in a Packerfile. Just the barebones attributes that are required for this class are specified here. The conversion of these attributes into a OS build specific file is done by derived classes in the OS specific directories.

Constants

IPV4

Constants

IPV6
STATIC

Attributes

dns[RW]
gateway[RW]
interface[RW]

Specify attributes

ip[RW]
mask[RW]
register[RW]
type[RW]

Public Class Methods

doc_file() click to toggle source

Documentation for this class

# File lib/PackerFiles/Core/Network.rb, line 30
def self.doc_file
   PackerFiles.DirPath('Core/example/Network.txt').first
end
new() { |self| ... } click to toggle source

Constructor to just specify accessor varibales

# File lib/PackerFiles/Core/Network.rb, line 35
def initialize
  @dns         = []
  yield self if block_given?
end

Public Instance Methods

is_static?() click to toggle source

Helper function to check if a static IP address is configured.

# File lib/PackerFiles/Core/Network.rb, line 41
def is_static?
  return ((@type & STATIC) > 0 )
end
normalize() click to toggle source

Normalize the various values into something useful. The default implementation checks only errors

# File lib/PackerFiles/Core/Network.rb, line 47
def normalize
 raise NilException.new(self, 'interface') if @interface.nil?
 raise NilException.new(self, 'type')      if @type.nil?
 raise 'Mixing IPV4 and IPV6'    if ((@type & IPV4) > 0) && ((@type & IPV6) > 0)
 if ( (@type & STATIC) > 0 )
    raise NilException.new(self, 'ip')       if @ip.nil?
    raise NilException.new(self, 'mask')     if @mask.nil?
    raise NilException.new(self, 'gateway')  if @gateway.nil?
    raise NilException.new(self, 'dns')      if @dns.nil?
    raise EmptyArrayException.new(self, 'dns')    if @dns.empty?
 else
   @register = true
 end
end