vaguerent/lib/vagrant/util/guest_inspection.rb
Chris Roberts 414184b76b guests/rhel: Update network configuration
Properly detects NetworkManager on guest as well as devices controlled
by NetworkManager. Provides configuration option to enable/disbale
NetworkManager control on devices.
2017-04-26 13:15:33 -07:00

48 lines
1.1 KiB
Ruby

module Vagrant
module Util
# Helper methods for inspecting guests to determine if specific services
# or applications are installed and in use
module GuestInspection
# Linux specific inspection helpers
module Linux
## systemd helpers
# systemd is in used
#
# @return [Boolean]
def systemd?(comm)
comm.test("systemctl | grep '^-\.mount'")
end
# systemd hostname set is via hostnamectl
#
# @return [Boolean]
def hostnamectl?(comm)
comm.test("hostnamectl")
end
## nmcli helpers
# nmcli is installed
#
# @return [Boolean]
def nmcli?(comm)
comm.test("nmcli")
end
# NetworkManager currently controls device
#
# @param comm [Communicator]
# @param device_name [String]
# @return [Boolean]
def nm_controlled?(comm, device_name)
comm.test("nmcli d show #{device_name}") &&
!comm.test("nmcli d show #{device_name} | grep unmanaged")
end
end
end
end
end