Class: OsVm::MachineConfig::SocketNetwork
- Inherits:
-
Network
- Object
- Network
- OsVm::MachineConfig::SocketNetwork
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) ⇒ SocketNetwork
Returns a new instance of SocketNetwork.
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
# File 'lib/osvm/machine_config.rb', line 166
def initialize(_i, cfg, allocate_resources: true)
super
mcast = cfg.fetch('mcast', {})
@mcast_address = mcast.fetch('address', '230.0.0.1')
mcast_port = mcast.fetch('port', 'net1')
@mcast_port =
case mcast_port
when String
PortReservation.get_port(key: "mcast:#{mcast_port}") if allocate_resources
when Integer
mcast_port
else
raise "Invalid mcast port value #{mcast_port.inspect} (expected string or a number)"
end
end
|
Instance Attribute Details
#mcast_address ⇒ String
161
162
163
|
# File 'lib/osvm/machine_config.rb', line 161
def mcast_address
@mcast_address
end
|
#mcast_port ⇒ Integer
164
165
166
|
# File 'lib/osvm/machine_config.rb', line 164
def mcast_port
@mcast_port
end
|
Instance Method Details
#qemu_options ⇒ Object
186
187
188
189
190
191
|
# File 'lib/osvm/machine_config.rb', line 186
def qemu_options
[
'-device', "#{model},netdev=net#{index},mac=#{mac}",
'-netdev', "socket,id=net#{index},mcast=#{mcast_address}:#{mcast_port}"
]
end
|