linux_admin
linux_admin copied to clipboard
Fix ip_route for appliction_console
On typical systems, ip_route calls ip route show default On the mac, ip_route calls ip route get while
This fixes ip_route from failing and fixes an appliance_console bug
before
# LinuxAdmin::NetworkInterface.list
route: writing to routing socket: not in table (LinuxAdmin::NetworkInterfaceError)
error was: route: writing to routing socket: not in table
error was: route: writing to routing socket: not in table
from /Users/kbrock/src/gems/linux_admin/lib/linux_admin/network_interface.rb:26:in `list'
from (irb):2:in `<main>'
from <internal:kernel>:187:in `loop'
from railties (7.0.8.6) lib/rails/commands/console/console_command.rb:74:in `start'
from railties (7.0.8.6) lib/rails/commands/console/console_command.rb:19:in `start'
after
# LinuxAdmin::NetworkInterface.list.first
=>
#<LinuxAdmin::NetworkInterfaceDarwin:0x0000000163fd2d98
@interface="lo0",
@link_type="loopback",
@network_conf={:address=>"127.0.0.1", :prefix=>8, :mac=>"00:00:00:00:00:00", :gateway4=>"192.168.1.1", :gateway6=>"fe80::%utun0"}>
Overall looks good - can you add specs for ip_route method?
My only other thought is, if we're going all the way to Darwin, should we try to avoid having to install iproute2mac, and use the built-in tools instead?
I do think at a high level we need to answer "do we want linux_admin to work on mac?" (emphasis on linux here)
We can get some of the networking commands to work but there are some other command sets which will not (systemd vs old init.d service, rpm packages, etc...) and we could need something like supports here.
I think the easy answer is "if it isn't difficult to get it to work we might as well" but how far do we want to go in order to get it to work? Also the specs should 100% be able to be run on a mac (here and appliance_console).
I'm ok with bringing in things bit by bit to support Mac. Heck, I'd be ok with supporting WSL too at some point :)
Agreed on something like supports here would be good. At a minimum we just raise NotImplementedError for certain things.
This pull request has been automatically marked as stale because it has not been updated for at least 3 months.
If these changes are still valid, please remove the stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).
update:
- fixed case statement
update:
- removed white space
@agrare I agree to the most part.
I don't want the appliance console to be able to administer the mac. I do want the appliance console to start up and the menus to work.
I introduced these changes so I could get the basics of appliance console running to upgrade the highline gem.
Also, NetworkInterface.new calls ip_show - not sure that a new should be making os calls. (Think this is the culprit for allow_any_instance_of)
spec/network_interface_spec.rb
- [ ] :warning: - 45 - Detected
allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
update:
- fixed
splitto not pass" "as an argument but pass nothing
lib/linux_admin/distro.rb
- [ ] :exclamation: - Line 26, Col 7 - Naming/MemoizedInstanceVariableName - Memoized variable
@distrosdoes not match method nameall. Use@allinstead.