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(cfg) ⇒ BridgeNetwork
constructor
A new instance of BridgeNetwork.
- #qemu_options ⇒ Object
Methods inherited from Network
Constructor Details
#initialize(cfg) ⇒ BridgeNetwork
Returns a new instance of BridgeNetwork.
98 99 100 101 102 |
# File 'lib/osvm/machine_config.rb', line 98 def initialize(cfg) super @link = @opts.fetch(:link) @mac = gen_mac_address end |
Instance Attribute Details
#link ⇒ String (readonly)
93 94 95 |
# File 'lib/osvm/machine_config.rb', line 93 def link @link end |
#mac ⇒ String (readonly)
96 97 98 |
# File 'lib/osvm/machine_config.rb', line 96 def mac @mac end |
Instance Method Details
#gen_mac_address ⇒ Object (protected)
113 114 115 |
# File 'lib/osvm/machine_config.rb', line 113 def gen_mac_address "00:60:2f:#{SecureRandom.hex(3).chars.each_slice(2).map(&:join).join(':')}" end |
#qemu_options ⇒ Object
104 105 106 107 108 109 |
# File 'lib/osvm/machine_config.rb', line 104 def [ '-device', "virtio-net,netdev=net1,mac=#{@mac}", '-netdev', "bridge,id=net1,br=#{link}" ] end |