Class: Y2Network::AutoinstProfile::RoutingSection

Inherits:
SectionWithAttributes show all
Defined in:
src/lib/y2network/autoinst_profile/routing_section.rb

Overview

This class represents an AutoYaST section under

false false <!-- see RouteSection class --> 192.168.1.0 eth0 foo - -

See Also:

Constant Summary

Constants inherited from SectionWithAttributes

SectionWithAttributes::VALUES_TO_SKIP

Instance Attribute Summary collapse

Attributes inherited from SectionWithAttributes

#parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SectionWithAttributes

#attribute_key, #attribute_name, #attribute_scalar, #attribute_skip?, #attribute_value, #attributes, define_attr_accessors, #init_scalars_from_hash, new_from_hashes, #section_name, #to_hashes

Constructor Details

#initialize(*_args) ⇒ RoutingSection

Constructor


73
74
75
76
# File 'src/lib/y2network/autoinst_profile/routing_section.rb', line 73

def initialize(*_args)
  super
  @routes = []
end

Instance Attribute Details

#ipv4_forwardBoolean

Returns:

  • (Boolean)

# File 'src/lib/y2network/autoinst_profile/routing_section.rb', line 53

#ipv6_forwardBoolean

Returns:

  • (Boolean)

# File 'src/lib/y2network/autoinst_profile/routing_section.rb', line 56

#routesArray<RouteSection>

Returns:


# File 'src/lib/y2network/autoinst_profile/routing_section.rb', line 59

Class Method Details

.attributesObject


43
44
45
46
47
48
49
# File 'src/lib/y2network/autoinst_profile/routing_section.rb', line 43

def self.attributes
  [
    { name: :ipv4_forward },
    { name: :ipv6_forward },
    { name: :routes }
  ]
end

.new_from_network(routing) ⇒ RoutingSection

Clones network routing settings into an AutoYaST routing section

Parameters:

Returns:


66
67
68
69
70
# File 'src/lib/y2network/autoinst_profile/routing_section.rb', line 66

def self.new_from_network(routing)
  result = new
  initialized = result.init_from_network(routing)
  initialized ? result : nil
end

Instance Method Details

#init_from_hashes(hash) ⇒ Object

Method used by SectionWithAttributes.new_from_hashes to populate the attributes when importing a profile

Parameters:


81
82
83
84
85
86
87
# File 'src/lib/y2network/autoinst_profile/routing_section.rb', line 81

def init_from_hashes(hash)
  super
  ip_forward = hash["ip_forward"]
  @ipv4_forward = hash["ipv4_forward"] || ip_forward
  @ipv6_forward = hash["ipv6_forward"] || ip_forward
  @routes = routes_from_hash(hash)
end

#init_from_network(routing) ⇒ Boolean

Method used by new_from_network to populate the attributes when cloning routing settings

Parameters:

Returns:

  • (Boolean)

    Result true on success or false otherwise


93
94
95
96
97
98
# File 'src/lib/y2network/autoinst_profile/routing_section.rb', line 93

def init_from_network(routing)
  @ipv4_forward = routing.forward_ipv4
  @ipv6_forward = routing.forward_ipv6
  @routes = routes_section(routing.routes)
  true
end