Class: OsVm::MachineConfig::Network

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

Direct Known Subclasses

BridgeNetwork, UserNetwork

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cfg) ⇒ Network

Returns a new instance of Network.



69
70
71
72
# File 'lib/osvm/machine_config.rb', line 69

def initialize(cfg)
  @mode = cfg.fetch(:mode)
  @opts = cfg.fetch(:opts, {})
end

Instance Attribute Details

#modeString (readonly)

Returns:

  • (String)


67
68
69
# File 'lib/osvm/machine_config.rb', line 67

def mode
  @mode
end

Class Method Details

.from_config(cfg) ⇒ Network

Returns:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/osvm/machine_config.rb', line 51

def self.from_config(cfg)
  mode = cfg.fetch(:mode)
  klass =
    case mode
    when 'user'
      UserNetwork
    when 'bridge'
      BridgeNetwork
    else
      raise ArgumentError, "unknown network mode #{mode.inspect}"
    end

  klass.new(cfg)
end

Instance Method Details

#qemu_optionsObject

Raises:

  • (NotImplementedError)


74
75
76
# File 'lib/osvm/machine_config.rb', line 74

def qemu_options
  raise NotImplementedError
end