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_LOOPBACK =
:loopback
MODE_DHCP =
:dhcp
PROTO_INET6 =
:inet6
PROTO_INET4 =
:inet
AUTO =
:auto

Instance Method Summary collapse

Constructor Details

#initialize(entry) ⇒ Header

Returns a new instance of Header.



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

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

Instance Method Details

#commitObject



274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 274

def commit
  return "" if @entry.skip_interfaces?
  ipv6_dhcp = "iface #{get_interface_name} inet6 dhcp" if @dhcpv6
  out = <<OUT
# #{@entry.iface.clazz}
#{@auto ? "auto #{get_interface_name}" : ""}
#{ipv6_dhcp||""}
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

#dhcpv4Object



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

def dhcpv4
  @mode = MODE_DHCP
  self
end

#dhcpv6Object



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

def dhcpv6
  @dhcpv6 = true
  self
end

#get_interface_nameObject



270
271
272
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 270

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

#interface_name(name) ⇒ Object



266
267
268
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 266

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



253
254
255
256
# File 'lib/construqt/flavour/ubuntu/flavour_ubuntu_result.rb', line 253

def noauto
  @auto = false
  self
end

#protocol(protocol) ⇒ Object



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

def protocol(protocol)
  @protocol = protocol
  self
end