Method: Bandshell.read_network_config
- Defined in:
- lib/bandshell/netconfig.rb
.read_network_config ⇒ Object
Read a JSON formatted network configuration from the config store. This instantiates the connection and addressing method classes and returns the instances i.e. cm, am = read_network_config
If no configuration is saved or it is corrupt this returns a default configuration that is somewhat likely to work.
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/bandshell/netconfig.rb', line 447 def self.read_network_config input = ConfigStore.read_config('network_config', '') begin args = JSON.parse(input) rescue # set up some sane defaults if we have no configuration # or it can't be parsed args = { 'connection_method' => 'WiredConnection', 'addressing_method' => 'DHCPAddressing', 'connection_method_args' => { }, 'addressing_method_args' => { } } end connection_method_class = Bandshell.const_get(args['connection_method']) addressing_method_class = Bandshell.const_get(args['addressing_method']) connection_method = connection_method_class.new( args['connection_method_args'] ) addressing_method = addressing_method_class.new( args['addressing_method_args'] ) return [connection_method, addressing_method] end |