Class: VagrantPlugins::ProviderZone::QGA::SystemdNetworkdBackend
- Inherits:
-
BaseBackend
- Object
- BaseBackend
- VagrantPlugins::ProviderZone::QGA::SystemdNetworkdBackend
- Defined in:
- lib/vagrant-zones/qga/systemd_networkd_backend.rb
Overview
Writes /etc/systemd/network/10-<vnic>.link (for MAC->name rename) and 10-<vnic>.network per NIC, then restarts systemd-networkd.
Constant Summary collapse
- NETWORKD_DIR =
'/etc/systemd/network'
Instance Method Summary collapse
Methods inherited from BaseBackend
Instance Method Details
#apply(uii, qga, nics, _ctx) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/vagrant-zones/qga/systemd_networkd_backend.rb', line 22 def apply(uii, qga, nics, _ctx) nics.each do |entry| write_link_file(qga, entry) write_network_file(qga, entry) uii.info("#{I18n.t('vagrant_zones.qga_backend_apply')} systemd-networkd #{entry[:vnic_name]}") end reload = qga.exec('/usr/bin/systemctl', args: %w[restart systemd-networkd], timeout: 30) raise Errors::QGAError, message: "systemd-networkd restart failed: #{reload[:stderr]}" if reload[:exitcode] != 0 end |
#cleanup(uii, qga, nics) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/vagrant-zones/qga/systemd_networkd_backend.rb', line 32 def cleanup(uii, qga, nics) nics.each do |entry| qga.exec('/bin/rm', args: ['-f', "#{NETWORKD_DIR}/10-#{entry[:vnic_name]}.link", "#{NETWORKD_DIR}/10-#{entry[:vnic_name]}.network"], timeout: 10) end qga.exec('/usr/bin/systemctl', args: %w[restart systemd-networkd], timeout: 30) uii.info("#{I18n.t('vagrant_zones.qga_backend_cleanup')} systemd-networkd") end |
#detect?(qga) ⇒ Boolean
13 14 15 16 17 18 19 20 |
# File 'lib/vagrant-zones/qga/systemd_networkd_backend.rb', line 13 def detect?(qga) return false unless qga.exec('/usr/bin/test', args: ['-d', NETWORKD_DIR], timeout: 10)[:exitcode].zero? result = qga.exec('/usr/bin/systemctl', args: %w[is-active systemd-networkd], timeout: 10) result[:stdout].to_s.strip == 'active' rescue StandardError false end |