16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/osctld/commands/net_interface/ip_del.rb', line 16
def execute(ct)
netif = ct.netifs[opts[:name]]
return error('network interface not found') unless netif
manipulate(ct) do
if opts[:addr] == 'all'
v = opts[:version] && opts[:version].to_i
case netif.type
when :routed
netif.del_all_ips(v, opts[:keep_route])
else
netif.del_all_ips(v)
end
else
addr = IPAddress.parse(opts[:addr])
ip_v = addr.ipv4? ? 4 : 6
error!('address not found') unless netif.has_ip?(addr)
case netif.type
when :routed
netif.del_ip(addr, opts[:keep_route])
else
netif.del_ip(addr)
end
end
ct.save_config
ct.lxc_config.configure_network
DistConfig.run(ct.get_run_conf, :network) if ct.can_dist_configure_network?
end
ok
end
|