Class: OsCtld::DistConfig::Network::SystemdNetworkd
- Inherits:
-
Base
- Object
- Base
- OsCtld::DistConfig::Network::SystemdNetworkd
show all
- Defined in:
- lib/osctld/dist_config/network/systemd_networkd.rb
Overview
Instance Attribute Summary
Attributes inherited from Base
#configurator
Instance Method Summary
collapse
Methods inherited from Base
#add_netif, #initialize
#systemd_service_enabled?, #systemd_service_masked?, #writable?
Instance Method Details
23
24
25
26
27
|
# File 'lib/osctld/dist_config/network/systemd_networkd.rb', line 23
def configure(netifs)
netifs.each do |netif|
do_create_netif(netif)
end
end
|
#do_create_netif(netif) ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/osctld/dist_config/network/systemd_networkd.rb', line 40
def do_create_netif(netif)
f = network_file(netif.name)
return unless writable?(f)
OsCtld::ErbTemplate.render_to_if_changed(
File.join('dist_config/network/systemd_networkd', netif.type.to_s),
{ netif: },
f
)
end
|
#do_remove_netif(name) ⇒ Object
51
52
53
54
55
56
|
# File 'lib/osctld/dist_config/network/systemd_networkd.rb', line 51
def do_remove_netif(name)
f = network_file(name)
return unless writable?(f)
unlink_if_exists(f)
end
|
#network_file(name) ⇒ Object
58
59
60
|
# File 'lib/osctld/dist_config/network/systemd_networkd.rb', line 58
def network_file(name)
File.join(rootfs, 'etc/systemd/network', "#{name}.network")
end
|
#remove_netif(_netifs, netif) ⇒ Object
29
30
31
|
# File 'lib/osctld/dist_config/network/systemd_networkd.rb', line 29
def remove_netif(_netifs, netif)
do_remove_netif(netif.name)
end
|
#rename_netif(_netifs, netif, old_name) ⇒ Object
33
34
35
36
|
# File 'lib/osctld/dist_config/network/systemd_networkd.rb', line 33
def rename_netif(_netifs, netif, old_name)
do_remove_netif(old_name)
do_create_netif(netif)
end
|
#usable? ⇒ Boolean
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/osctld/dist_config/network/systemd_networkd.rb', line 8
def usable?
service = 'systemd-networkd.service'
return false unless Dir.exist?(File.join(rootfs, 'etc/systemd/network'))
return false if systemd_service_masked?(service)
return false unless systemd_service_enabled?(service, 'multi-user.target')
true
end
|