Class: OsVm::MachineConfig::BridgeNetwork
- Defined in:
- lib/osvm/machine_config.rb
Instance Attribute Summary collapse
- #link ⇒ String readonly
- #mac ⇒ String readonly
Attributes inherited from Network
Instance Method Summary collapse
- #gen_mac_address ⇒ Object protected
-
#initialize(_i, cfg) ⇒ BridgeNetwork
constructor
A new instance of BridgeNetwork.
- #qemu_options ⇒ Object
Methods inherited from Network
Constructor Details
#initialize(_i, cfg) ⇒ BridgeNetwork
Returns a new instance of BridgeNetwork.
143 144 145 146 147 |
# File 'lib/osvm/machine_config.rb', line 143 def initialize(_i, cfg) super @link = @opts.fetch('link') @mac = @opts['mac'] || gen_mac_address end |
Instance Attribute Details
#link ⇒ String (readonly)
138 139 140 |
# File 'lib/osvm/machine_config.rb', line 138 def link @link end |
#mac ⇒ String (readonly)
141 142 143 |
# File 'lib/osvm/machine_config.rb', line 141 def mac @mac end |
Instance Method Details
#gen_mac_address ⇒ Object (protected)
158 159 160 |
# File 'lib/osvm/machine_config.rb', line 158 def gen_mac_address "00:60:2f:#{SecureRandom.hex(3).chars.each_slice(2).map(&:join).join(':')}" end |
#qemu_options ⇒ Object
149 150 151 152 153 154 |
# File 'lib/osvm/machine_config.rb', line 149 def [ '-device', "virtio-net,netdev=net#{index},mac=#{@mac}", '-netdev', "bridge,id=net#{index},br=#{link}" ] end |