kanrisuru 0.13.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/README.md +5 -5
- data/kanrisuru.gemspec +7 -3
- data/lib/kanrisuru/command.rb +15 -1
- data/lib/kanrisuru/core/apt/commands/autoclean.rb +13 -0
- data/lib/kanrisuru/core/apt/commands/autoremove.rb +15 -0
- data/lib/kanrisuru/core/apt/commands/clean.rb +13 -0
- data/lib/kanrisuru/core/apt/commands/full_upgrade.rb +14 -0
- data/lib/kanrisuru/core/apt/commands/install.rb +22 -0
- data/lib/kanrisuru/core/apt/commands/list.rb +21 -0
- data/lib/kanrisuru/core/apt/commands/purge.rb +18 -0
- data/lib/kanrisuru/core/apt/commands/remove.rb +18 -0
- data/lib/kanrisuru/core/apt/commands/search.rb +18 -0
- data/lib/kanrisuru/core/apt/commands/show.rb +21 -0
- data/lib/kanrisuru/core/apt/commands/update.rb +14 -0
- data/lib/kanrisuru/core/apt/commands/upgrade.rb +14 -0
- data/lib/kanrisuru/core/apt/commands.rb +14 -0
- data/lib/kanrisuru/core/apt/parser.rb +6 -0
- data/lib/kanrisuru/core/apt/parsers/base.rb +51 -0
- data/lib/kanrisuru/core/apt/parsers/list.rb +28 -0
- data/lib/kanrisuru/core/apt/parsers/search.rb +32 -0
- data/lib/kanrisuru/core/apt/parsers/show.rb +90 -0
- data/lib/kanrisuru/core/apt/types.rb +36 -0
- data/lib/kanrisuru/core/apt.rb +4 -284
- data/lib/kanrisuru/core/archive/commands/tar.rb +126 -0
- data/lib/kanrisuru/core/archive/commands.rb +3 -0
- data/lib/kanrisuru/core/archive/types.rb +9 -0
- data/lib/kanrisuru/core/archive.rb +3 -121
- data/lib/kanrisuru/core/disk/commands/blkid.rb +35 -0
- data/lib/kanrisuru/core/disk/commands/df.rb +26 -0
- data/lib/kanrisuru/core/disk/commands/du.rb +24 -0
- data/lib/kanrisuru/core/disk/commands/lsblk.rb +49 -0
- data/lib/kanrisuru/core/disk/commands.rb +6 -0
- data/lib/kanrisuru/core/disk/constants.rb +9 -0
- data/lib/kanrisuru/core/disk/parser.rb +7 -0
- data/lib/kanrisuru/core/disk/parsers/blkid.rb +72 -0
- data/lib/kanrisuru/core/disk/parsers/df.rb +33 -0
- data/lib/kanrisuru/core/disk/parsers/du.rb +25 -0
- data/lib/kanrisuru/core/disk/parsers/lsblk.rb +96 -0
- data/lib/kanrisuru/core/disk/parsers/lsblk_version.rb +21 -0
- data/lib/kanrisuru/core/disk/types.rb +21 -0
- data/lib/kanrisuru/core/disk.rb +6 -290
- data/lib/kanrisuru/core/dmi/commands/dmi.rb +42 -0
- data/lib/kanrisuru/core/dmi/commands.rb +3 -0
- data/lib/kanrisuru/core/dmi/parser.rb +3 -0
- data/lib/kanrisuru/core/dmi/parsers/dmi.rb +149 -0
- data/lib/kanrisuru/core/dmi/types.rb +361 -0
- data/lib/kanrisuru/core/dmi.rb +4 -522
- data/lib/kanrisuru/core/file/commands/chmod.rb +29 -0
- data/lib/kanrisuru/core/file/commands/chown.rb +35 -0
- data/lib/kanrisuru/core/file/commands/copy.rb +54 -0
- data/lib/kanrisuru/core/file/commands/link.rb +25 -0
- data/lib/kanrisuru/core/file/commands/mkdir.rb +42 -0
- data/lib/kanrisuru/core/file/commands/move.rb +48 -0
- data/lib/kanrisuru/core/file/commands/rm.rb +41 -0
- data/lib/kanrisuru/core/file/commands/symlink.rb +46 -0
- data/lib/kanrisuru/core/file/commands/touch.rb +34 -0
- data/lib/kanrisuru/core/file/commands/unlink.rb +13 -0
- data/lib/kanrisuru/core/file/commands/wc.rb +16 -0
- data/lib/kanrisuru/core/file/commands.rb +29 -0
- data/lib/kanrisuru/core/file/parser.rb +3 -0
- data/lib/kanrisuru/core/file/parsers/wc.rb +16 -0
- data/lib/kanrisuru/core/file/types.rb +9 -0
- data/lib/kanrisuru/core/file.rb +4 -312
- data/lib/kanrisuru/core/find/commands/find.rb +97 -0
- data/lib/kanrisuru/core/find/commands.rb +3 -0
- data/lib/kanrisuru/core/find/constants.rb +9 -0
- data/lib/kanrisuru/core/find/parser.rb +3 -0
- data/lib/kanrisuru/core/find/parsers/find.rb +18 -0
- data/lib/kanrisuru/core/find/types.rb +9 -0
- data/lib/kanrisuru/core/find.rb +5 -97
- data/lib/kanrisuru/core/group/commands/create_group.rb +21 -0
- data/lib/kanrisuru/core/group/commands/delete_group.rb +16 -0
- data/lib/kanrisuru/core/group/commands/get_gid.rb +17 -0
- data/lib/kanrisuru/core/group/commands/get_group.rb +29 -0
- data/lib/kanrisuru/core/group/commands/is_group.rb +14 -0
- data/lib/kanrisuru/core/group/commands/update_group.rb +23 -0
- data/lib/kanrisuru/core/group/commands.rb +8 -0
- data/lib/kanrisuru/core/group/parser.rb +4 -0
- data/lib/kanrisuru/core/group/parsers/gid.rb +15 -0
- data/lib/kanrisuru/core/group/parsers/group.rb +15 -0
- data/lib/kanrisuru/core/group/types.rb +10 -0
- data/lib/kanrisuru/core/group.rb +4 -81
- data/lib/kanrisuru/core/ip/commands/address.rb +86 -0
- data/lib/kanrisuru/core/ip/commands/address_label.rb +54 -0
- data/lib/kanrisuru/core/ip/commands/link.rb +116 -0
- data/lib/kanrisuru/core/ip/commands/link_set_opts.rb +61 -0
- data/lib/kanrisuru/core/ip/commands/link_type_opts.rb +313 -0
- data/lib/kanrisuru/core/ip/commands/maddress.rb +42 -0
- data/lib/kanrisuru/core/ip/commands/neighbour.rb +72 -0
- data/lib/kanrisuru/core/ip/commands/route.rb +152 -0
- data/lib/kanrisuru/core/ip/commands/rule.rb +57 -0
- data/lib/kanrisuru/core/ip/commands.rb +26 -0
- data/lib/kanrisuru/core/ip/constants.rb +25 -0
- data/lib/kanrisuru/core/ip/parser.rb +11 -0
- data/lib/kanrisuru/core/ip/parsers/address.rb +104 -0
- data/lib/kanrisuru/core/ip/parsers/address_label.rb +27 -0
- data/lib/kanrisuru/core/ip/parsers/base.rb +166 -0
- data/lib/kanrisuru/core/ip/parsers/link.rb +86 -0
- data/lib/kanrisuru/core/ip/parsers/maddress.rb +85 -0
- data/lib/kanrisuru/core/ip/parsers/neighbour.rb +89 -0
- data/lib/kanrisuru/core/ip/parsers/route.rb +76 -0
- data/lib/kanrisuru/core/ip/parsers/rule.rb +60 -0
- data/lib/kanrisuru/core/ip/parsers/version.rb +15 -0
- data/lib/kanrisuru/core/ip/types.rb +46 -0
- data/lib/kanrisuru/core/ip.rb +15 -1002
- data/lib/kanrisuru/core/mount/commands/mount.rb +65 -0
- data/lib/kanrisuru/core/mount/commands/umount.rb +35 -0
- data/lib/kanrisuru/core/mount/commands.rb +49 -0
- data/lib/kanrisuru/core/mount.rb +2 -125
- data/lib/kanrisuru/core/path/commands/ls.rb +26 -0
- data/lib/kanrisuru/core/path/commands/pwd.rb +16 -0
- data/lib/kanrisuru/core/path/commands/readlink.rb +22 -0
- data/lib/kanrisuru/core/path/commands/realpath.rb +18 -0
- data/lib/kanrisuru/core/path/commands/which.rb +19 -0
- data/lib/kanrisuru/core/path/commands/whoami.rb +16 -0
- data/lib/kanrisuru/core/path/commands.rb +8 -0
- data/lib/kanrisuru/core/path/parser.rb +4 -0
- data/lib/kanrisuru/core/path/parsers/ls.rb +53 -0
- data/lib/kanrisuru/core/path/parsers/which.rb +18 -0
- data/lib/kanrisuru/core/path/types.rb +12 -0
- data/lib/kanrisuru/core/path.rb +4 -121
- data/lib/kanrisuru/core/socket/commands/ss.rb +44 -0
- data/lib/kanrisuru/core/socket/commands.rb +3 -0
- data/lib/kanrisuru/core/socket/constants.rb +29 -0
- data/lib/kanrisuru/core/socket/parser.rb +3 -0
- data/lib/kanrisuru/core/socket/parsers/ss.rb +109 -0
- data/lib/kanrisuru/core/socket/types.rb +18 -0
- data/lib/kanrisuru/core/socket.rb +5 -164
- data/lib/kanrisuru/core/stat/commands/stat.rb +62 -0
- data/lib/kanrisuru/core/stat/commands.rb +3 -0
- data/lib/kanrisuru/core/stat/parser.rb +3 -0
- data/lib/kanrisuru/core/stat/parsers/stat.rb +34 -0
- data/lib/kanrisuru/core/stat/types.rb +14 -0
- data/lib/kanrisuru/core/stat.rb +4 -81
- data/lib/kanrisuru/core/stream/commands/cat.rb +25 -0
- data/lib/kanrisuru/core/stream/commands/echo.rb +20 -0
- data/lib/kanrisuru/core/stream/commands/head.rb +18 -0
- data/lib/kanrisuru/core/stream/commands/read_file_chunk.rb +21 -0
- data/lib/kanrisuru/core/stream/commands/sed.rb +23 -0
- data/lib/kanrisuru/core/stream/commands/tail.rb +18 -0
- data/lib/kanrisuru/core/stream/commands.rb +27 -0
- data/lib/kanrisuru/core/stream/parser.rb +4 -0
- data/lib/kanrisuru/core/stream/parsers/echo.rb +17 -0
- data/lib/kanrisuru/core/stream/parsers/sed.rb +17 -0
- data/lib/kanrisuru/core/stream.rb +3 -104
- data/lib/kanrisuru/core/system/commands/cpu_info.rb +32 -0
- data/lib/kanrisuru/core/system/commands/free.rb +25 -0
- data/lib/kanrisuru/core/system/commands/kernel_statistics.rb +21 -0
- data/lib/kanrisuru/core/system/commands/kill.rb +22 -0
- data/lib/kanrisuru/core/system/commands/last.rb +31 -0
- data/lib/kanrisuru/core/system/commands/load_average.rb +16 -0
- data/lib/kanrisuru/core/system/commands/load_env.rb +16 -0
- data/lib/kanrisuru/core/system/commands/lscpu.rb +17 -0
- data/lib/kanrisuru/core/system/commands/lsof.rb +16 -0
- data/lib/kanrisuru/core/system/commands/poweroff.rb +42 -0
- data/lib/kanrisuru/core/system/commands/ps.rb +35 -0
- data/lib/kanrisuru/core/system/commands/reboot.rb +42 -0
- data/lib/kanrisuru/core/system/commands/uptime.rb +18 -0
- data/lib/kanrisuru/core/system/commands/w.rb +24 -0
- data/lib/kanrisuru/core/system/commands.rb +34 -0
- data/lib/kanrisuru/core/system/parser.rb +11 -0
- data/lib/kanrisuru/core/system/parsers/kernel_statistics.rb +56 -0
- data/lib/kanrisuru/core/system/parsers/last.rb +64 -0
- data/lib/kanrisuru/core/system/parsers/load_average.rb +15 -0
- data/lib/kanrisuru/core/system/parsers/load_env.rb +24 -0
- data/lib/kanrisuru/core/system/parsers/lscpu.rb +90 -0
- data/lib/kanrisuru/core/system/parsers/lsof.rb +62 -0
- data/lib/kanrisuru/core/system/parsers/ps.rb +71 -0
- data/lib/kanrisuru/core/system/parsers/uptime.rb +38 -0
- data/lib/kanrisuru/core/system/parsers/w.rb +30 -0
- data/lib/kanrisuru/core/system/types.rb +108 -0
- data/lib/kanrisuru/core/system.rb +4 -687
- data/lib/kanrisuru/core/transfer/commands/download.rb +26 -0
- data/lib/kanrisuru/core/transfer/commands/upload.rb +23 -0
- data/lib/kanrisuru/core/transfer/commands/wget.rb +168 -0
- data/lib/kanrisuru/core/transfer/commands.rb +5 -0
- data/lib/kanrisuru/core/transfer/constants.rb +10 -0
- data/lib/kanrisuru/core/transfer.rb +3 -199
- data/lib/kanrisuru/core/user/commands/create_user.rb +49 -0
- data/lib/kanrisuru/core/user/commands/delete_user.rb +20 -0
- data/lib/kanrisuru/core/user/commands/get_uid.rb +15 -0
- data/lib/kanrisuru/core/user/commands/get_user.rb +48 -0
- data/lib/kanrisuru/core/user/commands/is_user.rb +14 -0
- data/lib/kanrisuru/core/user/commands/update_user.rb +54 -0
- data/lib/kanrisuru/core/user/commands.rb +8 -0
- data/lib/kanrisuru/core/user/parser.rb +4 -0
- data/lib/kanrisuru/core/user/parsers/getent.rb +17 -0
- data/lib/kanrisuru/core/user/parsers/groups.rb +17 -0
- data/lib/kanrisuru/core/user/types.rb +11 -0
- data/lib/kanrisuru/core/user.rb +4 -182
- data/lib/kanrisuru/core/yum/commands/autoremove.rb +14 -0
- data/lib/kanrisuru/core/yum/commands/clean.rb +23 -0
- data/lib/kanrisuru/core/yum/commands/erase.rb +20 -0
- data/lib/kanrisuru/core/yum/commands/info.rb +21 -0
- data/lib/kanrisuru/core/yum/commands/install.rb +18 -0
- data/lib/kanrisuru/core/yum/commands/list.rb +30 -0
- data/lib/kanrisuru/core/yum/commands/localinstall.rb +22 -0
- data/lib/kanrisuru/core/yum/commands/remove.rb +20 -0
- data/lib/kanrisuru/core/yum/commands/repolist.rb +20 -0
- data/lib/kanrisuru/core/yum/commands/search.rb +21 -0
- data/lib/kanrisuru/core/yum/commands/update.rb +14 -0
- data/lib/kanrisuru/core/yum/commands/upgrade.rb +14 -0
- data/lib/kanrisuru/core/yum/commands.rb +39 -0
- data/lib/kanrisuru/core/yum/parser.rb +7 -0
- data/lib/kanrisuru/core/yum/parsers/base.rb +31 -0
- data/lib/kanrisuru/core/yum/parsers/info.rb +69 -0
- data/lib/kanrisuru/core/yum/parsers/list.rb +24 -0
- data/lib/kanrisuru/core/yum/parsers/repolist.rb +60 -0
- data/lib/kanrisuru/core/yum/parsers/search.rb +30 -0
- data/lib/kanrisuru/core/yum/types.rb +41 -0
- data/lib/kanrisuru/core/yum.rb +4 -347
- data/lib/kanrisuru/core/zypper/commands/add_lock.rb +22 -0
- data/lib/kanrisuru/core/zypper/commands/add_repo.rb +38 -0
- data/lib/kanrisuru/core/zypper/commands/add_service.rb +26 -0
- data/lib/kanrisuru/core/zypper/commands/clean_cache.rb +22 -0
- data/lib/kanrisuru/core/zypper/commands/clean_locks.rb +17 -0
- data/lib/kanrisuru/core/zypper/commands/dist_upgrade.rb +25 -0
- data/lib/kanrisuru/core/zypper/commands/info.rb +25 -0
- data/lib/kanrisuru/core/zypper/commands/install.rb +39 -0
- data/lib/kanrisuru/core/zypper/commands/install_new_recommends.rb +23 -0
- data/lib/kanrisuru/core/zypper/commands/list_locks.rb +22 -0
- data/lib/kanrisuru/core/zypper/commands/list_patches.rb +34 -0
- data/lib/kanrisuru/core/zypper/commands/list_repos.rb +21 -0
- data/lib/kanrisuru/core/zypper/commands/list_services.rb +21 -0
- data/lib/kanrisuru/core/zypper/commands/list_updates.rb +30 -0
- data/lib/kanrisuru/core/zypper/commands/modify_repo.rb +48 -0
- data/lib/kanrisuru/core/zypper/commands/modify_service.rb +40 -0
- data/lib/kanrisuru/core/zypper/commands/patch.rb +40 -0
- data/lib/kanrisuru/core/zypper/commands/patch_check.rb +29 -0
- data/lib/kanrisuru/core/zypper/commands/purge_kernels.rb +18 -0
- data/lib/kanrisuru/core/zypper/commands/refresh_repos.rb +24 -0
- data/lib/kanrisuru/core/zypper/commands/refresh_services.rb +21 -0
- data/lib/kanrisuru/core/zypper/commands/remove.rb +26 -0
- data/lib/kanrisuru/core/zypper/commands/remove_lock.rb +22 -0
- data/lib/kanrisuru/core/zypper/commands/remove_repo.rb +32 -0
- data/lib/kanrisuru/core/zypper/commands/remove_service.rb +21 -0
- data/lib/kanrisuru/core/zypper/commands/rename_repo.rb +20 -0
- data/lib/kanrisuru/core/zypper/commands/search.rb +52 -0
- data/lib/kanrisuru/core/zypper/commands/source_install.rb +22 -0
- data/lib/kanrisuru/core/zypper/commands/update.rb +27 -0
- data/lib/kanrisuru/core/zypper/commands/verify.rb +23 -0
- data/lib/kanrisuru/core/zypper/commands.rb +109 -0
- data/lib/kanrisuru/core/zypper/constants.rb +19 -0
- data/lib/kanrisuru/core/zypper/parser.rb +11 -0
- data/lib/kanrisuru/core/zypper/parsers/base.rb +18 -0
- data/lib/kanrisuru/core/zypper/parsers/info.rb +77 -0
- data/lib/kanrisuru/core/zypper/parsers/list_locks.rb +36 -0
- data/lib/kanrisuru/core/zypper/parsers/list_patches.rb +40 -0
- data/lib/kanrisuru/core/zypper/parsers/list_repos.rb +37 -0
- data/lib/kanrisuru/core/zypper/parsers/list_services.rb +36 -0
- data/lib/kanrisuru/core/zypper/parsers/list_updates.rb +32 -0
- data/lib/kanrisuru/core/zypper/parsers/patch_check.rb +34 -0
- data/lib/kanrisuru/core/zypper/parsers/search.rb +37 -0
- data/lib/kanrisuru/core/zypper/types.rb +88 -0
- data/lib/kanrisuru/core/zypper.rb +5 -998
- data/lib/kanrisuru/os_package.rb +2 -0
- data/lib/kanrisuru/result.rb +15 -0
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/archive_spec.rb +1 -1
- data/spec/functional/core/disk_spec.rb +77 -0
- data/spec/functional/core/dmi_spec.rb +78 -0
- data/spec/functional/core/file_spec.rb +284 -0
- data/spec/functional/core/group_spec.rb +62 -0
- data/spec/functional/core/ip/ip_address_label_spec.rb +81 -0
- data/spec/functional/core/ip/ip_address_spec.rb +95 -0
- data/spec/functional/core/ip/ip_link_spec.rb +814 -0
- data/spec/functional/core/ip/ip_maddress_spec.rb +78 -0
- data/spec/functional/core/ip/ip_neighbour_spec.rb +119 -0
- data/spec/functional/core/ip/ip_route_spec.rb +174 -0
- data/spec/functional/core/ip/ip_rule_spec.rb +75 -0
- data/spec/functional/core/ip/ip_spec.rb +27 -0
- data/spec/functional/core/system_spec.rb +135 -0
- data/spec/functional/core/user_spec.rb +97 -0
- data/spec/functional/result_spec.rb +91 -44
- data/spec/helper/stub_network.rb +6 -2
- data/spec/support/shared_examples/integration/core/transfer.rb +1 -1
- data/spec/unit/command_spec.rb +2 -0
- data/spec/unit/core/ip_spec.rb +12 -0
- data/spec/unit/util_spec.rb +16 -0
- metadata +253 -4
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Core
|
5
|
+
module IP
|
6
|
+
def ip_link(action, opts)
|
7
|
+
case action
|
8
|
+
when 'show', 'list'
|
9
|
+
version = ip_version.to_i
|
10
|
+
command = ip_link_show(opts, version)
|
11
|
+
when 'add', 'a'
|
12
|
+
command = ip_link_add(opts)
|
13
|
+
when 'delete', 'del'
|
14
|
+
command = ip_link_delete(opts)
|
15
|
+
when 'set'
|
16
|
+
command = ip_link_set(opts)
|
17
|
+
end
|
18
|
+
|
19
|
+
execute_shell(command)
|
20
|
+
|
21
|
+
Kanrisuru::Result.new(command) do |cmd|
|
22
|
+
Parser::Link.parse(cmd, action, version)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def ip_link_show(opts, version)
|
27
|
+
command = Kanrisuru::Command.new('ip')
|
28
|
+
command.append_flag('-json') if version >= IPROUTE2_JSON_VERSION
|
29
|
+
command.append_flag('-s', opts[:stats])
|
30
|
+
command.append_arg('-family', opts[:family])
|
31
|
+
command << 'link show'
|
32
|
+
|
33
|
+
command.append_arg('dev', opts[:dev])
|
34
|
+
command.append_arg('group', opts[:group])
|
35
|
+
command.append_arg('master', opts[:master])
|
36
|
+
command.append_arg('type', opts[:type])
|
37
|
+
command.append_arg('vrf', opts[:vrf])
|
38
|
+
|
39
|
+
command.append_flag('up', opts[:up])
|
40
|
+
command
|
41
|
+
end
|
42
|
+
|
43
|
+
def ip_link_add(opts)
|
44
|
+
command = Kanrisuru::Command.new('ip link add')
|
45
|
+
|
46
|
+
command.append_arg('dev', opts[:dev])
|
47
|
+
command.append_arg('name', opts[:name])
|
48
|
+
command.append_arg('mtu', opts[:mtu])
|
49
|
+
command.append_arg('index', opts[:index])
|
50
|
+
|
51
|
+
command.append_arg('numtxqueues', opts[:numtxqueues])
|
52
|
+
command.append_arg('numrxqueues', opts[:numrxqueues])
|
53
|
+
command.append_arg('gso_max_size', opts[:gso_max_size])
|
54
|
+
command.append_arg('gso_max_segs', opts[:gso_max_segs])
|
55
|
+
|
56
|
+
if Kanrisuru::Util.present?(opts[:type])
|
57
|
+
raise ArgumentError, 'invalid link type' unless IP_LINK_TYPES.include?(opts[:type])
|
58
|
+
|
59
|
+
command.append_arg('type', opts[:type])
|
60
|
+
|
61
|
+
ip_link_type_opts(command, opts) if Kanrisuru::Util.present?(opts[:type_opts])
|
62
|
+
end
|
63
|
+
|
64
|
+
command
|
65
|
+
end
|
66
|
+
|
67
|
+
def ip_link_delete(opts)
|
68
|
+
command = Kanrisuru::Command.new('ip link delete')
|
69
|
+
command.append_arg('dev', opts[:dev])
|
70
|
+
command.append_arg('group', opts[:group])
|
71
|
+
command.append_arg('type', opts[:type])
|
72
|
+
command
|
73
|
+
end
|
74
|
+
|
75
|
+
def ip_link_set(opts)
|
76
|
+
command = Kanrisuru::Command.new('ip link set')
|
77
|
+
raise ArgumentError, 'no device defined' unless opts[:dev]
|
78
|
+
|
79
|
+
command.append_arg('dev', opts[:dev])
|
80
|
+
command.append_arg('group', opts[:group])
|
81
|
+
|
82
|
+
case opts[:direction]
|
83
|
+
when 'up'
|
84
|
+
command.append_flag('up')
|
85
|
+
when 'down'
|
86
|
+
command.append_flag('down')
|
87
|
+
end
|
88
|
+
|
89
|
+
ip_link_common_opts(command, opts)
|
90
|
+
|
91
|
+
ip_link_vf_opts(command, opts) if Kanrisuru::Util.present?(opts[:vf])
|
92
|
+
|
93
|
+
ip_link_xdp_opts(command, opts) if Kanrisuru::Util.present?(opts[:xdp])
|
94
|
+
|
95
|
+
if opts[:master] == false
|
96
|
+
command.append_flag('nomaster')
|
97
|
+
else
|
98
|
+
command.append_arg('master', opts[:master])
|
99
|
+
end
|
100
|
+
|
101
|
+
command.append_arg('addrgenmode', opts[:addrgenmode])
|
102
|
+
command.append_flag('link-netnsid', opts[:link_netnsid])
|
103
|
+
|
104
|
+
if Kanrisuru::Util.present?(opts[:type])
|
105
|
+
raise ArgumentError, 'invalid link type' unless IP_LINK_TYPES.include?(opts[:type])
|
106
|
+
|
107
|
+
command.append_arg('type', opts[:type])
|
108
|
+
|
109
|
+
ip_link_type_opts(command, opts) if Kanrisuru::Util.present?(opts[:type_opts])
|
110
|
+
end
|
111
|
+
|
112
|
+
command
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Core
|
5
|
+
module IP
|
6
|
+
def ip_link_common_opts(command, opts)
|
7
|
+
command.append_arg('arp', opts[:arp])
|
8
|
+
command.append_arg('multicast', opts[:multicast])
|
9
|
+
command.append_arg('allmulticast', opts[:allmulticast])
|
10
|
+
command.append_arg('promisc', opts[:promisc])
|
11
|
+
command.append_arg('protodown', opts[:protodown])
|
12
|
+
command.append_arg('protodown_reason', opts[:protodown_reason])
|
13
|
+
command.append_arg('dynamic', opts[:dynamic])
|
14
|
+
command.append_arg('name', opts[:name])
|
15
|
+
command.append_arg('txqueuelen', opts[:txqueuelen])
|
16
|
+
command.append_arg('txqlen', opts[:txqlen])
|
17
|
+
command.append_arg('mtu', opts[:mtu])
|
18
|
+
command.append_arg('address', opts[:address])
|
19
|
+
command.append_arg('broadcast', opts[:broadcast])
|
20
|
+
command.append_arg('brd', opts[:brd])
|
21
|
+
command.append_arg('peer', opts[:peer])
|
22
|
+
command.append_arg('netns', opts[:netns])
|
23
|
+
command.append_arg('alias', opts[:alias])
|
24
|
+
end
|
25
|
+
|
26
|
+
def ip_link_xdp_opts(command, opts)
|
27
|
+
command.append_arg('xdp', opts[:xdp])
|
28
|
+
|
29
|
+
case opts[:xdp]
|
30
|
+
when 'object'
|
31
|
+
command << opts[:object]
|
32
|
+
command.append_arg('section', opts[:section])
|
33
|
+
command.append_flag('verbose', opts[:verbose])
|
34
|
+
when 'pinned'
|
35
|
+
command << opts[:pinned]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def ip_link_vf_opts(command, opts)
|
40
|
+
command.append_arg('vf', opts[:vf])
|
41
|
+
command.append_arg('mac', opts[:mac])
|
42
|
+
|
43
|
+
if Kanrisuru::Util.present?(opts[:vlan])
|
44
|
+
command.append_arg('vlan', opts[:vlan])
|
45
|
+
command.append_arg('qos', opts[:qos])
|
46
|
+
end
|
47
|
+
|
48
|
+
command.append_arg('proto', opts[:proto])
|
49
|
+
command.append_arg('rate', opts[:rate])
|
50
|
+
command.append_arg('max_tx_rate', opts[:max_tx_rate])
|
51
|
+
command.append_arg('min_tx_rate', opts[:min_tx_rate])
|
52
|
+
command.append_arg('spoofchk', opts[:spoofchk])
|
53
|
+
command.append_arg('query_rss', opts[:query_rss])
|
54
|
+
command.append_arg('state', opts[:state])
|
55
|
+
command.append_arg('trust', opts[:trust])
|
56
|
+
command.append_arg('node_guid', opts[:node_guid])
|
57
|
+
command.append_arg('port_guid', opts[:port_guid])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,313 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Core
|
5
|
+
module IP
|
6
|
+
def ip_link_type_opts(command, opts)
|
7
|
+
case opts[:type]
|
8
|
+
when 'vlan'
|
9
|
+
ip_link_vlan_opts(command, opts[:type_opts])
|
10
|
+
when 'vxlan'
|
11
|
+
ip_link_vxlan_opts(command, opts[:type_opts])
|
12
|
+
when 'veth', 'vxcan'
|
13
|
+
ip_link_veth_vxcan_opts(command, opts[:type_opts])
|
14
|
+
when 'ipip', 'sit'
|
15
|
+
ip_link_ipip_sit_opts(command, opts[:type_opts])
|
16
|
+
when 'gre', 'gretap'
|
17
|
+
ip_link_gre_gretap_opts(command, opts[:type_opts])
|
18
|
+
when 'ip6gre', 'ip6gretap'
|
19
|
+
ip_link_ip6gre_ip6gretap_opts(command, opts[:type_opts])
|
20
|
+
when 'ipoib'
|
21
|
+
ip_link_ipoib_opts(command, opts[:type_opts])
|
22
|
+
when 'erspan', 'ip6erspan'
|
23
|
+
ip_link_erspan_opts(command, opts[:type_opts])
|
24
|
+
when 'geneve'
|
25
|
+
ip_link_geneve_opts(command, opts[:type_opts])
|
26
|
+
when 'bareudp'
|
27
|
+
ip_link_bareudp_opts(command, opts[:type_opts])
|
28
|
+
when 'macvlan', 'macvtap'
|
29
|
+
ip_link_macvlan_macvtap_opts(command, opts[:type_opts])
|
30
|
+
when 'hsr'
|
31
|
+
ip_link_hsr_opts(command, opts[:type_opts])
|
32
|
+
when 'bridge'
|
33
|
+
ip_link_bridge_opts(command, opts[:type_opts])
|
34
|
+
when 'macsec'
|
35
|
+
ip_link_macsec_opts(command, opts[:type_opts])
|
36
|
+
when 'vrf'
|
37
|
+
ip_link_vrf_opts(command, opts[:type_opts])
|
38
|
+
when 'rmnet'
|
39
|
+
ip_link_rmnet_opts(command, opts[:type_opts])
|
40
|
+
when 'xfrm'
|
41
|
+
ip_link_xfrm_opts(command, opts[:type_opts])
|
42
|
+
when 'bridge_slave'
|
43
|
+
ip_link_bridge_slave_opts(command, opts[:type_opts])
|
44
|
+
when 'bond_slave'
|
45
|
+
ip_link_bond_slave_opts(command, opts[:type_opts])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def ip_link_vlan_opts(command, opts)
|
50
|
+
command.append_arg('protocol', opts[:protocol])
|
51
|
+
command.append_arg('id', opts[:id])
|
52
|
+
command.append_arg('reorder_hdr', opts[:reorder_hdr])
|
53
|
+
command.append_arg('gvrp', opts[:gvrp])
|
54
|
+
command.append_arg('mvrp', opts[:mvrp])
|
55
|
+
command.append_arg('loose_binding', opts[:loose_binding])
|
56
|
+
command.append_arg('bridge_binding', opts[:bridge_binding])
|
57
|
+
command.append_arg('ingress-qos-map', opts[:ingress_qos_map])
|
58
|
+
command.append_arg('egress-qos-map', opts[:egress_qos_map])
|
59
|
+
end
|
60
|
+
|
61
|
+
def ip_link_vxlan_opts(command, opts)
|
62
|
+
command.append_arg('id', opts[:id])
|
63
|
+
command.append_arg('dev', opts[:dev])
|
64
|
+
command.append_arg('group', opts[:group])
|
65
|
+
command.append_arg('remote', opts[:remote])
|
66
|
+
command.append_arg('local', opts[:local])
|
67
|
+
command.append_arg('ttl', opts[:ttl])
|
68
|
+
command.append_arg('tos', opts[:tos])
|
69
|
+
command.append_arg('df', opts[:df])
|
70
|
+
command.append_arg('flowlabel', opts[:flowlabel])
|
71
|
+
command.append_arg('dstport', opts[:dstport])
|
72
|
+
command.append_arg('srcport', opts[:srcport])
|
73
|
+
|
74
|
+
command.append_flag_no('learning', opts[:learning])
|
75
|
+
command.append_flag_no('rsc', opts[:rsc])
|
76
|
+
command.append_flag_no('proxy', opts[:proxy])
|
77
|
+
command.append_flag_no('l2miss', opts[:l2miss])
|
78
|
+
command.append_flag_no('l3miss', opts[:l3miss])
|
79
|
+
command.append_flag_no('udpcsum', opts[:udpcsum])
|
80
|
+
command.append_flag_no('udp6zerocsumtx', opts[:udp6zerocsumtx])
|
81
|
+
command.append_flag_no('udp6zerocsumrx', opts[:udp6zerocsumrx])
|
82
|
+
|
83
|
+
command.append_arg('ageing', opts[:ageing])
|
84
|
+
command.append_arg('maxaddress', opts[:maxaddress])
|
85
|
+
|
86
|
+
command.append_flag('gbp', opts[:gbp])
|
87
|
+
command.append_flag('gpe', opts[:gpe])
|
88
|
+
end
|
89
|
+
|
90
|
+
def ip_link_veth_vxcan_opts(command, opts)
|
91
|
+
command.append_arg('peer name', opts[:peer_name])
|
92
|
+
end
|
93
|
+
|
94
|
+
def ip_link_ipip_sit_opts(command, opts)
|
95
|
+
ip_link_shared_sit_gre_opts(command, opts)
|
96
|
+
command.append_arg('mode', opts[:mode])
|
97
|
+
end
|
98
|
+
|
99
|
+
def ip_link_gre_gretap_opts(command, opts)
|
100
|
+
ip_link_shared_sit_gre_opts(command, opts)
|
101
|
+
ip_link_shared_io_opts(command, opts)
|
102
|
+
|
103
|
+
command.append_arg('ttl', opts[:ttl])
|
104
|
+
command.append_arg('tos', opts[:tos])
|
105
|
+
|
106
|
+
command.append_flag_no('pmtudisc', opts[:pmtudisc])
|
107
|
+
command.append_flag_no('ignore-df', opts[:ignore_df])
|
108
|
+
|
109
|
+
command.append_arg('dev', opts[:dev])
|
110
|
+
end
|
111
|
+
|
112
|
+
def ip_link_ip6gre_ip6gretap_opts(command, opts)
|
113
|
+
command.append_arg('remote', opts[:remote])
|
114
|
+
command.append_arg('local', opts[:local])
|
115
|
+
ip_link_shared_io_opts(command, opts)
|
116
|
+
|
117
|
+
command.append_arg('hoplimit', opts[:hoplimit])
|
118
|
+
command.append_arg('encaplimit', opts[:encaplimit])
|
119
|
+
command.append_arg('flowlabel', opts[:flowlabel])
|
120
|
+
|
121
|
+
command.append_flag_no('allow-localremote', opts[:allow_localremote])
|
122
|
+
command.append_arg('tclass', opts[:tclass])
|
123
|
+
command.append_arg('external', opts[:external])
|
124
|
+
end
|
125
|
+
|
126
|
+
def ip_link_ipoib_opts(command, opts)
|
127
|
+
command.append_arg('pkey', opts[:pkey])
|
128
|
+
command.append_arg('mode', opts[:mode])
|
129
|
+
end
|
130
|
+
|
131
|
+
def ip_link_erspan_opts(command, opts)
|
132
|
+
command.append_arg('remote', opts[:remote])
|
133
|
+
command.append_arg('local', opts[:local])
|
134
|
+
command.append_arg('erspan_ver', opts[:erspan_ver])
|
135
|
+
command.append_arg('erspan', opts[:erspan])
|
136
|
+
command.append_arg('erspan_dir', opts[:erspan_dir])
|
137
|
+
command.append_arg('erspan_hwid', opts[:erspan_hwid])
|
138
|
+
command.append_flag_no('allow-localremote', opts[:allow_localremote])
|
139
|
+
command.append_flag('external', opts[:external])
|
140
|
+
end
|
141
|
+
|
142
|
+
def ip_link_geneve_opts(command, opts)
|
143
|
+
command.append_arg('id', opts[:id])
|
144
|
+
command.append_arg('remote', opts[:remote])
|
145
|
+
command.append_arg('ttl', opts[:ttl])
|
146
|
+
command.append_arg('tos', opts[:tos])
|
147
|
+
command.append_arg('df', opts[:df])
|
148
|
+
command.append_arg('flowlabel', opts[:flowlabel])
|
149
|
+
command.append_arg('dstport', opts[:dstport])
|
150
|
+
|
151
|
+
command.append_flag_no('external', opts[:external])
|
152
|
+
command.append_flag_no('udpcsum', opts[:udpcsum])
|
153
|
+
command.append_flag_no('udp6zerocsumtx', opts[:udp6zerocsumtx])
|
154
|
+
command.append_flag_no('udp6zerocsumrx', opts[:udp6zerocsumrx])
|
155
|
+
end
|
156
|
+
|
157
|
+
def ip_link_bareudp_opts(command, opts)
|
158
|
+
command.append_arg('dstport', opts[:dstport])
|
159
|
+
command.append_arg('ethertype', opts[:ethertype])
|
160
|
+
command.append_arg('srcportmin', opts[:srcportmin])
|
161
|
+
command.append_flag_no('multiproto', opts[:multiproto])
|
162
|
+
end
|
163
|
+
|
164
|
+
def ip_link_macvlan_macvtap_opts(command, opts)
|
165
|
+
command.append_arg('mode', opts[:mode])
|
166
|
+
command.append_arg('flag', opts[:flag])
|
167
|
+
|
168
|
+
case opts[:mode_opts]
|
169
|
+
when 'add', 'del'
|
170
|
+
command << opts[:mode_opts]
|
171
|
+
command << opts[:mac_address]
|
172
|
+
when 'set'
|
173
|
+
command << 'set'
|
174
|
+
command.append_array(opts[:mac_address])
|
175
|
+
when 'flush'
|
176
|
+
command << 'flush'
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def ip_link_hsr_opts(command, opts)
|
181
|
+
command.append_arg('slave1', opts[:slave1])
|
182
|
+
command.append_arg('slave2', opts[:slave2])
|
183
|
+
command.append_arg('supervision', opts[:supervision])
|
184
|
+
command.append_arg('version', opts[:version])
|
185
|
+
command.append_arg('proto', opts[:proto])
|
186
|
+
end
|
187
|
+
|
188
|
+
def ip_link_bridge_opts(command, opts)
|
189
|
+
command.append_arg('ageing_time', opts[:ageing_time])
|
190
|
+
command.append_arg('group_fwd_mask', opts[:group_fwd_mask])
|
191
|
+
command.append_arg('group_address', opts[:group_address])
|
192
|
+
command.append_arg('forward_delay', opts[:forward_delay])
|
193
|
+
command.append_arg('hello_time', opts[:hello_time])
|
194
|
+
command.append_arg('max_age', opts[:max_age])
|
195
|
+
command.append_arg('stp_state', opts[:stp_state])
|
196
|
+
command.append_arg('priority', opts[:priority])
|
197
|
+
command.append_arg('vlan_filtering', opts[:vlan_filtering])
|
198
|
+
command.append_arg('vlan_protocol', opts[:vlan_protocol])
|
199
|
+
command.append_arg('vlan_default_pvid', opts[:vlan_default_pvid])
|
200
|
+
command.append_arg('vlan_stats_enabled', opts[:vlan_stats_enabled])
|
201
|
+
command.append_arg('vlan_stats_per_port', opts[:vlan_stats_per_port])
|
202
|
+
command.append_arg('mcast_snooping', opts[:mcast_snooping])
|
203
|
+
command.append_arg('mcast_router', opts[:mcast_router])
|
204
|
+
command.append_arg('mcast_query_use_ifaddr', opts[:mcast_query_use_ifaddr])
|
205
|
+
command.append_arg('mcast_querier', opts[:mcast_querier])
|
206
|
+
command.append_arg('mcast_querier_interval', opts[:mcast_querier_interval])
|
207
|
+
command.append_arg('mcast_hash_elasticity', opts[:mcast_hash_elasticity])
|
208
|
+
command.append_arg('mcast_hash_max', opts[:mcast_hash_max])
|
209
|
+
command.append_arg('mcast_last_member_count', opts[:mcast_last_member_count])
|
210
|
+
command.append_arg('mcast_last_member_interval', opts[:mcast_last_member_interval])
|
211
|
+
command.append_arg('mcast_startup_query_count', opts[:mcast_startup_query_count])
|
212
|
+
command.append_arg('mcast_startup_query_interval', opts[:mcast_startup_query_interval])
|
213
|
+
command.append_arg('mcast_query_interval', opts[:mcast_query_interval])
|
214
|
+
command.append_arg('mcast_query_response_interval', opts[:mcast_query_response_interval])
|
215
|
+
command.append_arg('mcast_membership_interval', opts[:mcast_membership_interval])
|
216
|
+
command.append_arg('mcast_stats_enabled', opts[:mcast_stats_enabled])
|
217
|
+
command.append_arg('mcast_igmp_version', opts[:mcast_igmp_version])
|
218
|
+
command.append_arg('mcast_mld_version', opts[:mcast_mld_version])
|
219
|
+
command.append_arg('nf_call_iptables', opts[:nf_call_iptables])
|
220
|
+
command.append_arg('nf_call_ip6tables', opts[:nf_call_ip6tables])
|
221
|
+
command.append_arg('nf_call_arptables', opts[:nf_call_arptables])
|
222
|
+
end
|
223
|
+
|
224
|
+
def ip_link_macsec_opts(command, opts)
|
225
|
+
command.append_arg('address', opts[:address])
|
226
|
+
command.append_arg('port', opts[:port])
|
227
|
+
command.append_arg('sci', opts[:sci])
|
228
|
+
command.append_arg('cipher', opts[:cipher])
|
229
|
+
command.append_arg('icvlen', opts[:icvlen])
|
230
|
+
command.append_arg('encrypt', opts[:encrypt])
|
231
|
+
command.append_arg('send_sci', opts[:send_sci])
|
232
|
+
command.append_arg('end_station', opts[:end_station])
|
233
|
+
command.append_arg('scb', opts[:scb])
|
234
|
+
command.append_arg('protect', opts[:protect])
|
235
|
+
command.append_arg('replay', opts[:replay])
|
236
|
+
command.append_arg('window', opts[:window])
|
237
|
+
command.append_arg('validate', opts[:validate])
|
238
|
+
command.append_arg('encodingsa', opts[:encodingsa])
|
239
|
+
end
|
240
|
+
|
241
|
+
def ip_link_vrf_opts(command, opts)
|
242
|
+
command.append_arg('table', opts[:table])
|
243
|
+
end
|
244
|
+
|
245
|
+
def ip_link_rmnet_opts(command, opts)
|
246
|
+
command.append_arg('mux_id', opts[:mux_id])
|
247
|
+
end
|
248
|
+
|
249
|
+
def ip_link_xfrm_opts(command, opts)
|
250
|
+
command.append_arg('if_id', opts[:if_id])
|
251
|
+
end
|
252
|
+
|
253
|
+
def ip_link_bridge_slave_opts(command, opts)
|
254
|
+
command.append_flag('fdb_flush', opts[:fdb_flush])
|
255
|
+
command.append_arg('state', opts[:state])
|
256
|
+
command.append_arg('priority', opts[:priority])
|
257
|
+
command.append_arg('cost', opts[:cost])
|
258
|
+
command.append_arg('guard', opts[:guard])
|
259
|
+
command.append_arg('hairpin', opts[:hairpin])
|
260
|
+
command.append_arg('fastleave', opts[:fastleave])
|
261
|
+
command.append_arg('root_block', opts[:root_block])
|
262
|
+
command.append_arg('learning', opts[:learning])
|
263
|
+
command.append_arg('flood', opts[:flood])
|
264
|
+
command.append_arg('proxy_arp', opts[:proxy_arp])
|
265
|
+
command.append_arg('proxy_arp_wifi', opts[:proxy_arp_wifi])
|
266
|
+
command.append_arg('mcast_router', opts[:mcast_router])
|
267
|
+
command.append_arg('mcast_fast_leave', opts[:mcast_fast_leave])
|
268
|
+
command.append_arg('mcast_flood', opts[:mcast_flood])
|
269
|
+
command.append_arg('mcast_to_unicast', opts[:mcast_to_unicast])
|
270
|
+
command.append_arg('group_fwd_mask', opts[:group_fwd_mask])
|
271
|
+
command.append_arg('neigh_suppress', opts[:neigh_suppress])
|
272
|
+
command.append_arg('neigh_suppress', opts[:neigh_suppress])
|
273
|
+
command.append_arg('backup_port', opts[:backup_port])
|
274
|
+
command.append_flag('nobackup_port', opts[:nobackup_port])
|
275
|
+
end
|
276
|
+
|
277
|
+
def ip_link_bond_slave_opts(command, opts)
|
278
|
+
command.append_arg('queue_id', opts[:queue_id])
|
279
|
+
end
|
280
|
+
|
281
|
+
def ip_link_shared_io_opts(command, opts)
|
282
|
+
command.append_flag_no('iseq', opts[:iseq])
|
283
|
+
command.append_flag_no('oseq', opts[:oseq])
|
284
|
+
|
285
|
+
command.append_flag_no('icsum', opts[:icsum])
|
286
|
+
command.append_flag_no('ocsum', opts[:ocsum])
|
287
|
+
|
288
|
+
if opts[:okey] == false
|
289
|
+
command.append_flag('nookey', opts[:okey])
|
290
|
+
elsif opts[:okey].instance_of?(Integer)
|
291
|
+
command.append_arg('okey', opts[:okey])
|
292
|
+
end
|
293
|
+
|
294
|
+
if opts[:ikey] == false
|
295
|
+
command.append_flag('noikey', opts[:ikey])
|
296
|
+
elsif opts[:ikey].instance_of?(Integer)
|
297
|
+
command.append_arg('ikey', opts[:ikey])
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
def ip_link_shared_sit_gre_opts(command, opts)
|
302
|
+
command.append_arg('remote', opts[:remote])
|
303
|
+
command.append_arg('local', opts[:local])
|
304
|
+
command.append_arg('encap', opts[:encap])
|
305
|
+
command.append_arg('encap-sport', opts[:encap_sport])
|
306
|
+
|
307
|
+
command.append_flag_no('encap-csum', opts[:encap_csum])
|
308
|
+
command.append_flag_no('encap-remcsum', opts[:encap_remcsum])
|
309
|
+
command.append_flag('external', opts[:external])
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Core
|
5
|
+
module IP
|
6
|
+
def ip_maddress(action, opts)
|
7
|
+
case action
|
8
|
+
when 'show', 'list'
|
9
|
+
version = ip_version.to_i
|
10
|
+
command = ip_maddress_show(opts, version)
|
11
|
+
when 'add', 'delete', 'del'
|
12
|
+
command = ip_maddress_modify(action, opts)
|
13
|
+
end
|
14
|
+
|
15
|
+
execute_shell(command)
|
16
|
+
|
17
|
+
Kanrisuru::Result.new(command) do |cmd|
|
18
|
+
Parser::Maddress.parse(cmd, action, version)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def ip_maddress_show(opts, version)
|
23
|
+
command = Kanrisuru::Command.new('ip')
|
24
|
+
command.append_flag('-json') if version >= IPROUTE2_JSON_VERSION
|
25
|
+
command.append_arg('-family', opts[:family])
|
26
|
+
command << 'maddress show'
|
27
|
+
|
28
|
+
command.append_arg('dev', opts[:dev])
|
29
|
+
command
|
30
|
+
end
|
31
|
+
|
32
|
+
def ip_maddress_modify(action, opts)
|
33
|
+
command = Kanrisuru::Command.new('ip maddress')
|
34
|
+
command << action
|
35
|
+
|
36
|
+
command.append_arg('address', opts[:address])
|
37
|
+
command.append_arg('dev', opts[:dev])
|
38
|
+
command
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Core
|
5
|
+
module IP
|
6
|
+
def ip_neighbour(action, opts)
|
7
|
+
case action
|
8
|
+
when 'show', 'list'
|
9
|
+
version = ip_version.to_i
|
10
|
+
command = ip_neighbour_show(opts, version)
|
11
|
+
when 'add', 'change', 'replace', 'del', 'delete'
|
12
|
+
command = ip_neighbour_modify(action, opts)
|
13
|
+
when 'flush'
|
14
|
+
command = ip_neighbour_flush(opts)
|
15
|
+
end
|
16
|
+
|
17
|
+
execute_shell(command)
|
18
|
+
|
19
|
+
Kanrisuru::Result.new(command) do |cmd|
|
20
|
+
Parser::Neighbour.parse(cmd, action, version)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def ip_neighbour_show(opts, version)
|
25
|
+
command = Kanrisuru::Command.new('ip')
|
26
|
+
command.append_flag('-json') if version >= IPROUTE2_JSON_VERSION
|
27
|
+
command.append_flag('-s', opts[:stats])
|
28
|
+
|
29
|
+
command << 'neighbour show'
|
30
|
+
|
31
|
+
command.append_arg('to', opts[:to])
|
32
|
+
command.append_arg('dev', opts[:dev])
|
33
|
+
command.append_arg('nud', opts[:nud])
|
34
|
+
|
35
|
+
command.append_flag('proxy', opts[:proxy])
|
36
|
+
command.append_flag('unused', opts[:unused])
|
37
|
+
command
|
38
|
+
end
|
39
|
+
|
40
|
+
def ip_neighbour_modify(action, opts)
|
41
|
+
command = Kanrisuru::Command.new('ip neighbour')
|
42
|
+
command << action
|
43
|
+
|
44
|
+
command.append_arg('to', opts[:to])
|
45
|
+
command.append_arg('dev', opts[:dev])
|
46
|
+
|
47
|
+
if action != 'del' && action != 'delete'
|
48
|
+
command.append_arg('lladdr', opts[:lladdr])
|
49
|
+
command.append_arg('nud', opts[:nud])
|
50
|
+
end
|
51
|
+
|
52
|
+
command.append_flag('proxy', opts[:proxy])
|
53
|
+
command.append_flag('router', opts[:router])
|
54
|
+
command.append_flag('extern_learn', opts[:extern_learn])
|
55
|
+
command
|
56
|
+
end
|
57
|
+
|
58
|
+
def ip_neighbour_flush(opts)
|
59
|
+
command = Kanrisuru::Command.new('ip')
|
60
|
+
command.append_flag('-s', opts[:stats])
|
61
|
+
command << 'neighbour flush'
|
62
|
+
|
63
|
+
command.append_arg('to', opts[:to])
|
64
|
+
command.append_arg('dev', opts[:dev])
|
65
|
+
command.append_arg('nud', opts[:nud])
|
66
|
+
|
67
|
+
command.append_flag('unused', opts[:unused])
|
68
|
+
command
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|