linux_admin icon indicating copy to clipboard operation
linux_admin copied to clipboard

Fix ip_route for appliction_console

Open kbrock opened this issue 1 year ago • 7 comments

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"}>

kbrock avatar Dec 09 '24 15:12 kbrock

Overall looks good - can you add specs for ip_route method?

Fryguy avatar Dec 09 '24 20:12 Fryguy

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?

Fryguy avatar Dec 09 '24 20:12 Fryguy

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.

agrare avatar Dec 09 '24 20:12 agrare

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).

agrare avatar Dec 09 '24 20:12 agrare

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.

Fryguy avatar Dec 09 '24 21:12 Fryguy

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).

miq-bot avatar Apr 14 '25 00:04 miq-bot

update:

  • fixed case statement

kbrock avatar Jun 04 '25 14:06 kbrock

update:

  • removed white space

kbrock avatar Jun 06 '25 18:06 kbrock

@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)

kbrock avatar Jun 06 '25 18:06 kbrock

Some comments on commit https://github.com/kbrock/linux_admin/commit/b49f1d31b25f136ea20939968b747a2daded34d4

spec/network_interface_spec.rb

  • [ ] :warning: - 45 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

miq-bot avatar Jun 06 '25 19:06 miq-bot

update:

  • fixed split to not pass " " as an argument but pass nothing

kbrock avatar Jun 06 '25 19:06 kbrock

Checked commit https://github.com/kbrock/linux_admin/commit/b49f1d31b25f136ea20939968b747a2daded34d4 with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.62.0, and yamllint 7 files checked, 1 offense detected

lib/linux_admin/distro.rb

miq-bot avatar Jun 06 '25 19:06 miq-bot