Class: OsVm::MachineConfig::BridgeNetwork

Inherits:
Network
  • Object
show all
Defined in:
lib/osvm/machine_config.rb

Instance Attribute Summary collapse

Attributes inherited from Network

#index, #mac, #model, #type

Instance Method Summary collapse

Methods inherited from Network

#default_opts, from_config, #resolve_mac_address, #resolve_model

Constructor Details

#initialize(_i, cfg, allocate_resources: true) ⇒ BridgeNetwork

Returns a new instance of BridgeNetwork.



201
202
203
204
205
# File 'lib/osvm/machine_config.rb', line 201

def initialize(_i, cfg, allocate_resources: true)
  super
  @link = @opts.fetch('link')
  @helper = @opts['helper']&.to_s
end

Instance Attribute Details

#helper ⇒ String? (readonly)

Returns:

  • (String, nil)


199
200
201
# File 'lib/osvm/machine_config.rb', line 199

def helper
  @helper
end

Returns:

  • (String)


196
197
198
# File 'lib/osvm/machine_config.rb', line 196

def link
  @link
end

Instance Method Details

#qemu_options ⇒ Object



207
208
209
210
211
212
213
214
215
# File 'lib/osvm/machine_config.rb', line 207

def qemu_options
  netdev = "bridge,id=net#{index},br=#{link}"
  netdev << ",helper=#{helper}" unless helper.nil? || helper.empty?

  [
    '-device', "#{model},netdev=net#{index},mac=#{mac}",
    '-netdev', netdev
  ]
end