Class: Y2Network::VirtualizationConfig
- Inherits:
-
Object
- Object
- Y2Network::VirtualizationConfig
- Includes:
- Yast::Logger
- Defined in:
- src/lib/y2network/virtualization_config.rb
Overview
This class is responsible for creating a bridge configuration for virtualization from the interfaces that are connected and bridgeable.
Instance Attribute Summary collapse
- #config ⇒ Y2Network::Config readonly
Instance Method Summary collapse
-
#bridgeable_candidates ⇒ Array<Y2Network::Interface]
Obtains the interfaces that are candidates for being bridgeable.
-
#create ⇒ Boolean
Iterates over the bridgeable candidates creating a bridge for each of them.
-
#initialize(config) ⇒ VirtualizationConfig
constructor
Constructor.
Constructor Details
#initialize(config) ⇒ VirtualizationConfig
Constructor
34 35 36 |
# File 'src/lib/y2network/virtualization_config.rb', line 34 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Y2Network::Config (readonly)
29 30 31 |
# File 'src/lib/y2network/virtualization_config.rb', line 29 def config @config end |
Instance Method Details
#bridgeable_candidates ⇒ Array<Y2Network::Interface]
Obtains the interfaces that are candidates for being bridgeable
41 42 43 44 45 46 |
# File 'src/lib/y2network/virtualization_config.rb', line 41 def bridgeable_candidates builder = Y2Network::InterfaceConfigBuilder.for("br") builder.name = config.interfaces.free_name("br") config.interfaces.select { |i| connected_and_bridgeable?(builder, i) } end |
#create ⇒ Boolean
Iterates over the bridgeable candidates creating a bridge for each of them. The connection is copied to the bridge when exist and the interface is added as a bridge port
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'src/lib/y2network/virtualization_config.rb', line 53 def create return false if bridgeable_candidates.empty? bridgeable_candidates.each do |interface| bridge_builder = bridge_builder_for(interface) connection = config.connections.by_name(interface.name) # The configuration of the connection being included is copied to the # bridge when exist bridge_builder.configure_from(connection) if connection builder = Y2Network::InterfaceConfigBuilder.for(interface.type, config: connection) builder.name = interface.name builder.configure_as_port builder.save # It adds the connection and the virtual interface bridge_builder.save # Move routes from the port member to the bridge (bsc#903889) move_routes(builder.name, bridge_builder.name) end true end |