Class: Construqt::Flavour::Ubuntu::EtcNetworkInterfaces::Entry::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb

Constant Summary collapse

MODE_MANUAL =
:manual
MODE_DHCP =
:dhcp
MODE_LOOPBACK =
:loopback
PROTO_INET6 =
:inet6
PROTO_INET4 =
:inet
AUTO =
:auto

Instance Method Summary collapse

Constructor Details

#initialize(entry) ⇒ Header

Returns a new instance of Header.



248
249
250
251
252
253
254
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 248

def initialize(entry)
  @entry = entry
  @auto = true
  @mode = MODE_MANUAL
  @protocol = PROTO_INET4
  @interface_name = nil
end

Instance Method Details

#commitObject



264
265
266
267
268
269
270
271
272
273
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 264

def commit
  return "" if @entry.skip_interfaces?
  out = <<OUT
# #{@entry.iface.clazz}
#{@auto ? "auto #{get_interface_name}" : ""}
iface #{get_interface_name} #{@protocol.to_s} #{@mode.to_s}
  up   /bin/bash /etc/network/#{get_interface_name}-up.iface
  down /bin/bash /etc/network/#{get_interface_name}-down.iface
OUT
end

#get_interface_nameObject



260
261
262
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 260

def get_interface_name
  @interface_name || @entry.iface.name
end

#interface_name(name) ⇒ Object



256
257
258
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 256

def interface_name(name)
  @interface_name = name
end

#mode(mode) ⇒ Object



233
234
235
236
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 233

def mode(mode)
  @mode = mode
  self
end

#noautoObject



243
244
245
246
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 243

def noauto
  @auto = false
  self
end

#protocol(protocol) ⇒ Object



238
239
240
241
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 238

def protocol(protocol)
  @protocol = protocol
  self
end