kanrisuru 0.12.1 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (489) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/README.md +5 -5
  4. data/kanrisuru.gemspec +7 -3
  5. data/lib/kanrisuru/command.rb +15 -1
  6. data/lib/kanrisuru/core/apt/commands/autoclean.rb +13 -0
  7. data/lib/kanrisuru/core/apt/commands/autoremove.rb +15 -0
  8. data/lib/kanrisuru/core/apt/commands/clean.rb +13 -0
  9. data/lib/kanrisuru/core/apt/commands/full_upgrade.rb +14 -0
  10. data/lib/kanrisuru/core/apt/commands/install.rb +22 -0
  11. data/lib/kanrisuru/core/apt/commands/list.rb +21 -0
  12. data/lib/kanrisuru/core/apt/commands/purge.rb +18 -0
  13. data/lib/kanrisuru/core/apt/commands/remove.rb +18 -0
  14. data/lib/kanrisuru/core/apt/commands/search.rb +18 -0
  15. data/lib/kanrisuru/core/apt/commands/show.rb +21 -0
  16. data/lib/kanrisuru/core/apt/commands/update.rb +14 -0
  17. data/lib/kanrisuru/core/apt/commands/upgrade.rb +14 -0
  18. data/lib/kanrisuru/core/apt/commands.rb +14 -0
  19. data/lib/kanrisuru/core/apt/parser.rb +6 -0
  20. data/lib/kanrisuru/core/apt/parsers/base.rb +51 -0
  21. data/lib/kanrisuru/core/apt/parsers/list.rb +28 -0
  22. data/lib/kanrisuru/core/apt/parsers/search.rb +32 -0
  23. data/lib/kanrisuru/core/apt/parsers/show.rb +90 -0
  24. data/lib/kanrisuru/core/apt/types.rb +36 -0
  25. data/lib/kanrisuru/core/apt.rb +4 -284
  26. data/lib/kanrisuru/core/archive/commands/tar.rb +126 -0
  27. data/lib/kanrisuru/core/archive/commands.rb +3 -0
  28. data/lib/kanrisuru/core/archive/types.rb +9 -0
  29. data/lib/kanrisuru/core/archive.rb +3 -121
  30. data/lib/kanrisuru/core/disk/commands/blkid.rb +35 -0
  31. data/lib/kanrisuru/core/disk/commands/df.rb +26 -0
  32. data/lib/kanrisuru/core/disk/commands/du.rb +24 -0
  33. data/lib/kanrisuru/core/disk/commands/lsblk.rb +49 -0
  34. data/lib/kanrisuru/core/disk/commands.rb +6 -0
  35. data/lib/kanrisuru/core/disk/constants.rb +9 -0
  36. data/lib/kanrisuru/core/disk/parser.rb +7 -0
  37. data/lib/kanrisuru/core/disk/parsers/blkid.rb +72 -0
  38. data/lib/kanrisuru/core/disk/parsers/df.rb +33 -0
  39. data/lib/kanrisuru/core/disk/parsers/du.rb +25 -0
  40. data/lib/kanrisuru/core/disk/parsers/lsblk.rb +96 -0
  41. data/lib/kanrisuru/core/disk/parsers/lsblk_version.rb +21 -0
  42. data/lib/kanrisuru/core/disk/types.rb +21 -0
  43. data/lib/kanrisuru/core/disk.rb +6 -290
  44. data/lib/kanrisuru/core/dmi/commands/dmi.rb +42 -0
  45. data/lib/kanrisuru/core/dmi/commands.rb +3 -0
  46. data/lib/kanrisuru/core/dmi/parser.rb +3 -0
  47. data/lib/kanrisuru/core/dmi/parsers/dmi.rb +149 -0
  48. data/lib/kanrisuru/core/dmi/types.rb +361 -0
  49. data/lib/kanrisuru/core/dmi.rb +4 -522
  50. data/lib/kanrisuru/core/file/commands/chmod.rb +29 -0
  51. data/lib/kanrisuru/core/file/commands/chown.rb +35 -0
  52. data/lib/kanrisuru/core/file/commands/copy.rb +54 -0
  53. data/lib/kanrisuru/core/file/commands/link.rb +25 -0
  54. data/lib/kanrisuru/core/file/commands/mkdir.rb +42 -0
  55. data/lib/kanrisuru/core/file/commands/move.rb +48 -0
  56. data/lib/kanrisuru/core/file/commands/rm.rb +41 -0
  57. data/lib/kanrisuru/core/file/commands/symlink.rb +46 -0
  58. data/lib/kanrisuru/core/file/commands/touch.rb +34 -0
  59. data/lib/kanrisuru/core/file/commands/unlink.rb +13 -0
  60. data/lib/kanrisuru/core/file/commands/wc.rb +16 -0
  61. data/lib/kanrisuru/core/file/commands.rb +29 -0
  62. data/lib/kanrisuru/core/file/parser.rb +3 -0
  63. data/lib/kanrisuru/core/file/parsers/wc.rb +16 -0
  64. data/lib/kanrisuru/core/file/types.rb +9 -0
  65. data/lib/kanrisuru/core/file.rb +4 -312
  66. data/lib/kanrisuru/core/find/commands/find.rb +97 -0
  67. data/lib/kanrisuru/core/find/commands.rb +3 -0
  68. data/lib/kanrisuru/core/find/constants.rb +9 -0
  69. data/lib/kanrisuru/core/find/parser.rb +3 -0
  70. data/lib/kanrisuru/core/find/parsers/find.rb +18 -0
  71. data/lib/kanrisuru/core/find/types.rb +9 -0
  72. data/lib/kanrisuru/core/find.rb +5 -97
  73. data/lib/kanrisuru/core/group/commands/create_group.rb +21 -0
  74. data/lib/kanrisuru/core/group/commands/delete_group.rb +16 -0
  75. data/lib/kanrisuru/core/group/commands/get_gid.rb +17 -0
  76. data/lib/kanrisuru/core/group/commands/get_group.rb +29 -0
  77. data/lib/kanrisuru/core/group/commands/is_group.rb +14 -0
  78. data/lib/kanrisuru/core/group/commands/update_group.rb +23 -0
  79. data/lib/kanrisuru/core/group/commands.rb +8 -0
  80. data/lib/kanrisuru/core/group/parser.rb +4 -0
  81. data/lib/kanrisuru/core/group/parsers/gid.rb +15 -0
  82. data/lib/kanrisuru/core/group/parsers/group.rb +15 -0
  83. data/lib/kanrisuru/core/group/types.rb +10 -0
  84. data/lib/kanrisuru/core/group.rb +4 -81
  85. data/lib/kanrisuru/core/ip/commands/address.rb +86 -0
  86. data/lib/kanrisuru/core/ip/commands/address_label.rb +54 -0
  87. data/lib/kanrisuru/core/ip/commands/link.rb +116 -0
  88. data/lib/kanrisuru/core/ip/commands/link_set_opts.rb +61 -0
  89. data/lib/kanrisuru/core/ip/commands/link_type_opts.rb +313 -0
  90. data/lib/kanrisuru/core/ip/commands/maddress.rb +42 -0
  91. data/lib/kanrisuru/core/ip/commands/neighbour.rb +72 -0
  92. data/lib/kanrisuru/core/ip/commands/route.rb +152 -0
  93. data/lib/kanrisuru/core/ip/commands/rule.rb +57 -0
  94. data/lib/kanrisuru/core/ip/commands.rb +26 -0
  95. data/lib/kanrisuru/core/ip/constants.rb +25 -0
  96. data/lib/kanrisuru/core/ip/parser.rb +11 -0
  97. data/lib/kanrisuru/core/ip/parsers/address.rb +104 -0
  98. data/lib/kanrisuru/core/ip/parsers/address_label.rb +27 -0
  99. data/lib/kanrisuru/core/ip/parsers/base.rb +166 -0
  100. data/lib/kanrisuru/core/ip/parsers/link.rb +86 -0
  101. data/lib/kanrisuru/core/ip/parsers/maddress.rb +85 -0
  102. data/lib/kanrisuru/core/ip/parsers/neighbour.rb +89 -0
  103. data/lib/kanrisuru/core/ip/parsers/route.rb +76 -0
  104. data/lib/kanrisuru/core/ip/parsers/rule.rb +60 -0
  105. data/lib/kanrisuru/core/ip/parsers/version.rb +15 -0
  106. data/lib/kanrisuru/core/ip/types.rb +46 -0
  107. data/lib/kanrisuru/core/ip.rb +15 -1002
  108. data/lib/kanrisuru/core/mount/commands/mount.rb +65 -0
  109. data/lib/kanrisuru/core/mount/commands/umount.rb +35 -0
  110. data/lib/kanrisuru/core/mount/commands.rb +49 -0
  111. data/lib/kanrisuru/core/mount.rb +2 -125
  112. data/lib/kanrisuru/core/path/commands/ls.rb +26 -0
  113. data/lib/kanrisuru/core/path/commands/pwd.rb +16 -0
  114. data/lib/kanrisuru/core/path/commands/readlink.rb +22 -0
  115. data/lib/kanrisuru/core/path/commands/realpath.rb +18 -0
  116. data/lib/kanrisuru/core/path/commands/which.rb +19 -0
  117. data/lib/kanrisuru/core/path/commands/whoami.rb +16 -0
  118. data/lib/kanrisuru/core/path/commands.rb +8 -0
  119. data/lib/kanrisuru/core/path/parser.rb +4 -0
  120. data/lib/kanrisuru/core/path/parsers/ls.rb +53 -0
  121. data/lib/kanrisuru/core/path/parsers/which.rb +18 -0
  122. data/lib/kanrisuru/core/path/types.rb +12 -0
  123. data/lib/kanrisuru/core/path.rb +4 -121
  124. data/lib/kanrisuru/core/socket/commands/ss.rb +44 -0
  125. data/lib/kanrisuru/core/socket/commands.rb +3 -0
  126. data/lib/kanrisuru/core/socket/constants.rb +29 -0
  127. data/lib/kanrisuru/core/socket/parser.rb +3 -0
  128. data/lib/kanrisuru/core/socket/parsers/ss.rb +109 -0
  129. data/lib/kanrisuru/core/socket/types.rb +18 -0
  130. data/lib/kanrisuru/core/socket.rb +5 -164
  131. data/lib/kanrisuru/core/stat/commands/stat.rb +62 -0
  132. data/lib/kanrisuru/core/stat/commands.rb +3 -0
  133. data/lib/kanrisuru/core/stat/parser.rb +3 -0
  134. data/lib/kanrisuru/core/stat/parsers/stat.rb +34 -0
  135. data/lib/kanrisuru/core/stat/types.rb +14 -0
  136. data/lib/kanrisuru/core/stat.rb +4 -81
  137. data/lib/kanrisuru/core/stream/commands/cat.rb +25 -0
  138. data/lib/kanrisuru/core/stream/commands/echo.rb +20 -0
  139. data/lib/kanrisuru/core/stream/commands/head.rb +18 -0
  140. data/lib/kanrisuru/core/stream/commands/read_file_chunk.rb +21 -0
  141. data/lib/kanrisuru/core/stream/commands/sed.rb +23 -0
  142. data/lib/kanrisuru/core/stream/commands/tail.rb +18 -0
  143. data/lib/kanrisuru/core/stream/commands.rb +27 -0
  144. data/lib/kanrisuru/core/stream/parser.rb +4 -0
  145. data/lib/kanrisuru/core/stream/parsers/echo.rb +17 -0
  146. data/lib/kanrisuru/core/stream/parsers/sed.rb +17 -0
  147. data/lib/kanrisuru/core/stream.rb +3 -104
  148. data/lib/kanrisuru/core/system/commands/cpu_info.rb +32 -0
  149. data/lib/kanrisuru/core/system/commands/free.rb +25 -0
  150. data/lib/kanrisuru/core/system/commands/kernel_statistics.rb +21 -0
  151. data/lib/kanrisuru/core/system/commands/kill.rb +22 -0
  152. data/lib/kanrisuru/core/system/commands/last.rb +31 -0
  153. data/lib/kanrisuru/core/system/commands/load_average.rb +16 -0
  154. data/lib/kanrisuru/core/system/commands/load_env.rb +16 -0
  155. data/lib/kanrisuru/core/system/commands/lscpu.rb +17 -0
  156. data/lib/kanrisuru/core/system/commands/lsof.rb +16 -0
  157. data/lib/kanrisuru/core/system/commands/poweroff.rb +42 -0
  158. data/lib/kanrisuru/core/system/commands/ps.rb +35 -0
  159. data/lib/kanrisuru/core/system/commands/reboot.rb +42 -0
  160. data/lib/kanrisuru/core/system/commands/uptime.rb +18 -0
  161. data/lib/kanrisuru/core/system/commands/w.rb +24 -0
  162. data/lib/kanrisuru/core/system/commands.rb +34 -0
  163. data/lib/kanrisuru/core/system/parser.rb +11 -0
  164. data/lib/kanrisuru/core/system/parsers/kernel_statistics.rb +56 -0
  165. data/lib/kanrisuru/core/system/parsers/last.rb +64 -0
  166. data/lib/kanrisuru/core/system/parsers/load_average.rb +15 -0
  167. data/lib/kanrisuru/core/system/parsers/load_env.rb +24 -0
  168. data/lib/kanrisuru/core/system/parsers/lscpu.rb +90 -0
  169. data/lib/kanrisuru/core/system/parsers/lsof.rb +62 -0
  170. data/lib/kanrisuru/core/system/parsers/ps.rb +71 -0
  171. data/lib/kanrisuru/core/system/parsers/uptime.rb +38 -0
  172. data/lib/kanrisuru/core/system/parsers/w.rb +30 -0
  173. data/lib/kanrisuru/core/system/types.rb +108 -0
  174. data/lib/kanrisuru/core/system.rb +4 -687
  175. data/lib/kanrisuru/core/transfer/commands/download.rb +26 -0
  176. data/lib/kanrisuru/core/transfer/commands/upload.rb +23 -0
  177. data/lib/kanrisuru/core/transfer/commands/wget.rb +168 -0
  178. data/lib/kanrisuru/core/transfer/commands.rb +5 -0
  179. data/lib/kanrisuru/core/transfer/constants.rb +10 -0
  180. data/lib/kanrisuru/core/transfer.rb +3 -199
  181. data/lib/kanrisuru/core/user/commands/create_user.rb +49 -0
  182. data/lib/kanrisuru/core/user/commands/delete_user.rb +20 -0
  183. data/lib/kanrisuru/core/user/commands/get_uid.rb +15 -0
  184. data/lib/kanrisuru/core/user/commands/get_user.rb +48 -0
  185. data/lib/kanrisuru/core/user/commands/is_user.rb +14 -0
  186. data/lib/kanrisuru/core/user/commands/update_user.rb +54 -0
  187. data/lib/kanrisuru/core/user/commands.rb +8 -0
  188. data/lib/kanrisuru/core/user/parser.rb +4 -0
  189. data/lib/kanrisuru/core/user/parsers/getent.rb +17 -0
  190. data/lib/kanrisuru/core/user/parsers/groups.rb +17 -0
  191. data/lib/kanrisuru/core/user/types.rb +11 -0
  192. data/lib/kanrisuru/core/user.rb +4 -182
  193. data/lib/kanrisuru/core/yum/commands/autoremove.rb +14 -0
  194. data/lib/kanrisuru/core/yum/commands/clean.rb +23 -0
  195. data/lib/kanrisuru/core/yum/commands/erase.rb +20 -0
  196. data/lib/kanrisuru/core/yum/commands/info.rb +21 -0
  197. data/lib/kanrisuru/core/yum/commands/install.rb +18 -0
  198. data/lib/kanrisuru/core/yum/commands/list.rb +30 -0
  199. data/lib/kanrisuru/core/yum/commands/localinstall.rb +22 -0
  200. data/lib/kanrisuru/core/yum/commands/remove.rb +20 -0
  201. data/lib/kanrisuru/core/yum/commands/repolist.rb +20 -0
  202. data/lib/kanrisuru/core/yum/commands/search.rb +21 -0
  203. data/lib/kanrisuru/core/yum/commands/update.rb +14 -0
  204. data/lib/kanrisuru/core/yum/commands/upgrade.rb +14 -0
  205. data/lib/kanrisuru/core/yum/commands.rb +39 -0
  206. data/lib/kanrisuru/core/yum/parser.rb +7 -0
  207. data/lib/kanrisuru/core/yum/parsers/base.rb +31 -0
  208. data/lib/kanrisuru/core/yum/parsers/info.rb +69 -0
  209. data/lib/kanrisuru/core/yum/parsers/list.rb +24 -0
  210. data/lib/kanrisuru/core/yum/parsers/repolist.rb +60 -0
  211. data/lib/kanrisuru/core/yum/parsers/search.rb +30 -0
  212. data/lib/kanrisuru/core/yum/types.rb +41 -0
  213. data/lib/kanrisuru/core/yum.rb +4 -347
  214. data/lib/kanrisuru/core/zypper/commands/add_lock.rb +22 -0
  215. data/lib/kanrisuru/core/zypper/commands/add_repo.rb +38 -0
  216. data/lib/kanrisuru/core/zypper/commands/add_service.rb +26 -0
  217. data/lib/kanrisuru/core/zypper/commands/clean_cache.rb +22 -0
  218. data/lib/kanrisuru/core/zypper/commands/clean_locks.rb +17 -0
  219. data/lib/kanrisuru/core/zypper/commands/dist_upgrade.rb +25 -0
  220. data/lib/kanrisuru/core/zypper/commands/info.rb +25 -0
  221. data/lib/kanrisuru/core/zypper/commands/install.rb +39 -0
  222. data/lib/kanrisuru/core/zypper/commands/install_new_recommends.rb +23 -0
  223. data/lib/kanrisuru/core/zypper/commands/list_locks.rb +22 -0
  224. data/lib/kanrisuru/core/zypper/commands/list_patches.rb +34 -0
  225. data/lib/kanrisuru/core/zypper/commands/list_repos.rb +21 -0
  226. data/lib/kanrisuru/core/zypper/commands/list_services.rb +21 -0
  227. data/lib/kanrisuru/core/zypper/commands/list_updates.rb +30 -0
  228. data/lib/kanrisuru/core/zypper/commands/modify_repo.rb +48 -0
  229. data/lib/kanrisuru/core/zypper/commands/modify_service.rb +40 -0
  230. data/lib/kanrisuru/core/zypper/commands/patch.rb +40 -0
  231. data/lib/kanrisuru/core/zypper/commands/patch_check.rb +29 -0
  232. data/lib/kanrisuru/core/zypper/commands/purge_kernels.rb +18 -0
  233. data/lib/kanrisuru/core/zypper/commands/refresh_repos.rb +24 -0
  234. data/lib/kanrisuru/core/zypper/commands/refresh_services.rb +21 -0
  235. data/lib/kanrisuru/core/zypper/commands/remove.rb +26 -0
  236. data/lib/kanrisuru/core/zypper/commands/remove_lock.rb +22 -0
  237. data/lib/kanrisuru/core/zypper/commands/remove_repo.rb +32 -0
  238. data/lib/kanrisuru/core/zypper/commands/remove_service.rb +21 -0
  239. data/lib/kanrisuru/core/zypper/commands/rename_repo.rb +20 -0
  240. data/lib/kanrisuru/core/zypper/commands/search.rb +52 -0
  241. data/lib/kanrisuru/core/zypper/commands/source_install.rb +22 -0
  242. data/lib/kanrisuru/core/zypper/commands/update.rb +27 -0
  243. data/lib/kanrisuru/core/zypper/commands/verify.rb +23 -0
  244. data/lib/kanrisuru/core/zypper/commands.rb +109 -0
  245. data/lib/kanrisuru/core/zypper/constants.rb +19 -0
  246. data/lib/kanrisuru/core/zypper/parser.rb +11 -0
  247. data/lib/kanrisuru/core/zypper/parsers/base.rb +18 -0
  248. data/lib/kanrisuru/core/zypper/parsers/info.rb +77 -0
  249. data/lib/kanrisuru/core/zypper/parsers/list_locks.rb +36 -0
  250. data/lib/kanrisuru/core/zypper/parsers/list_patches.rb +40 -0
  251. data/lib/kanrisuru/core/zypper/parsers/list_repos.rb +37 -0
  252. data/lib/kanrisuru/core/zypper/parsers/list_services.rb +36 -0
  253. data/lib/kanrisuru/core/zypper/parsers/list_updates.rb +32 -0
  254. data/lib/kanrisuru/core/zypper/parsers/patch_check.rb +34 -0
  255. data/lib/kanrisuru/core/zypper/parsers/search.rb +37 -0
  256. data/lib/kanrisuru/core/zypper/types.rb +88 -0
  257. data/lib/kanrisuru/core/zypper.rb +5 -998
  258. data/lib/kanrisuru/result.rb +15 -0
  259. data/lib/kanrisuru/version.rb +1 -1
  260. data/spec/functional/core/archive_spec.rb +1 -1
  261. data/spec/functional/core/disk_spec.rb +77 -0
  262. data/spec/functional/core/dmi_spec.rb +78 -0
  263. data/spec/functional/core/file_spec.rb +284 -0
  264. data/spec/functional/core/group_spec.rb +62 -0
  265. data/spec/functional/core/ip/ip_address_label_spec.rb +81 -0
  266. data/spec/functional/core/ip/ip_address_spec.rb +95 -0
  267. data/spec/functional/core/ip/ip_link_spec.rb +814 -0
  268. data/spec/functional/core/ip/ip_maddress_spec.rb +78 -0
  269. data/spec/functional/core/ip/ip_neighbour_spec.rb +119 -0
  270. data/spec/functional/core/ip/ip_route_spec.rb +174 -0
  271. data/spec/functional/core/ip/ip_rule_spec.rb +75 -0
  272. data/spec/functional/core/ip/ip_spec.rb +27 -0
  273. data/spec/functional/core/system_spec.rb +135 -0
  274. data/spec/functional/core/user_spec.rb +97 -0
  275. data/spec/functional/result_spec.rb +197 -0
  276. data/spec/{hosts.json → helper/hosts.json} +0 -0
  277. data/spec/helper/simplecov.rb +21 -0
  278. data/spec/helper/stub_network.rb +6 -2
  279. data/spec/helper/test_hosts.rb +1 -1
  280. data/spec/integration/core/apt/debian_spec.rb +9 -0
  281. data/spec/integration/core/apt/ubuntu_spec.rb +9 -0
  282. data/spec/integration/core/archive/centos_spec.rb +9 -0
  283. data/spec/integration/core/archive/debian_spec.rb +9 -0
  284. data/spec/integration/core/archive/fedora_spec.rb +9 -0
  285. data/spec/integration/core/archive/opensuse_spec.rb +9 -0
  286. data/spec/integration/core/archive/rhel_spec.rb +9 -0
  287. data/spec/integration/core/archive/sles_spec.rb +9 -0
  288. data/spec/integration/core/archive/ubuntu_spec.rb +9 -0
  289. data/spec/integration/core/disk/centos_spec.rb +9 -0
  290. data/spec/integration/core/disk/debian_spec.rb +9 -0
  291. data/spec/integration/core/disk/fedora_spec.rb +9 -0
  292. data/spec/integration/core/disk/opensuse_spec.rb +9 -0
  293. data/spec/integration/core/disk/rhel_spec.rb +9 -0
  294. data/spec/integration/core/disk/sles_spec.rb +9 -0
  295. data/spec/integration/core/disk/ubuntu_spec.rb +9 -0
  296. data/spec/integration/core/dmi/centos_spec.rb +9 -0
  297. data/spec/integration/core/dmi/debian_spec.rb +9 -0
  298. data/spec/integration/core/dmi/fedora_spec.rb +9 -0
  299. data/spec/integration/core/dmi/opensuse_spec.rb +9 -0
  300. data/spec/integration/core/dmi/rhel_spec.rb +9 -0
  301. data/spec/integration/core/dmi/sles_spec.rb +9 -0
  302. data/spec/integration/core/dmi/ubuntu_spec.rb +9 -0
  303. data/spec/integration/core/file/centos_spec.rb +9 -0
  304. data/spec/integration/core/file/debian_spec.rb +9 -0
  305. data/spec/integration/core/file/fedora_spec.rb +9 -0
  306. data/spec/integration/core/file/opensuse_spec.rb +9 -0
  307. data/spec/integration/core/file/rhel_spec.rb +9 -0
  308. data/spec/integration/core/file/sles_spec.rb +9 -0
  309. data/spec/integration/core/file/ubuntu_spec.rb +9 -0
  310. data/spec/integration/core/find/centos_spec.rb +9 -0
  311. data/spec/integration/core/find/debian_spec.rb +9 -0
  312. data/spec/integration/core/find/fedora_spec.rb +9 -0
  313. data/spec/integration/core/find/opensuse_spec.rb +9 -0
  314. data/spec/integration/core/find/rhel_spec.rb +9 -0
  315. data/spec/integration/core/find/sles_spec.rb +9 -0
  316. data/spec/integration/core/find/ubuntu_spec.rb +9 -0
  317. data/spec/integration/core/group/centos_spec.rb +9 -0
  318. data/spec/integration/core/group/debian_spec.rb +9 -0
  319. data/spec/integration/core/group/fedora_spec.rb +9 -0
  320. data/spec/integration/core/group/opensuse_spec.rb +9 -0
  321. data/spec/integration/core/group/rhel_spec.rb +9 -0
  322. data/spec/integration/core/group/sles_spec.rb +9 -0
  323. data/spec/integration/core/group/ubuntu_spec.rb +9 -0
  324. data/spec/integration/core/ip/centos_spec.rb +9 -0
  325. data/spec/integration/core/ip/debian_spec.rb +9 -0
  326. data/spec/integration/core/ip/fedora_spec.rb +9 -0
  327. data/spec/integration/core/ip/opensuse_spec.rb +9 -0
  328. data/spec/integration/core/ip/rhel_spec.rb +9 -0
  329. data/spec/integration/core/ip/sles_spec.rb +9 -0
  330. data/spec/integration/core/ip/ubuntu_spec.rb +9 -0
  331. data/spec/integration/core/path/centos_spec.rb +9 -0
  332. data/spec/integration/core/path/debian_spec.rb +9 -0
  333. data/spec/integration/core/path/fedora_spec.rb +9 -0
  334. data/spec/integration/core/path/opensuse_spec.rb +9 -0
  335. data/spec/integration/core/path/rhel_spec.rb +9 -0
  336. data/spec/integration/core/path/sles_spec.rb +9 -0
  337. data/spec/integration/core/path/ubuntu_spec.rb +9 -0
  338. data/spec/integration/core/socket/centos_spec.rb +9 -0
  339. data/spec/integration/core/socket/debian_spec.rb +9 -0
  340. data/spec/integration/core/socket/fedora_spec.rb +9 -0
  341. data/spec/integration/core/socket/opensuse_spec.rb +9 -0
  342. data/spec/integration/core/socket/rhel_spec.rb +9 -0
  343. data/spec/integration/core/socket/sles_spec.rb +9 -0
  344. data/spec/integration/core/socket/ubuntu_spec.rb +9 -0
  345. data/spec/integration/core/stat/centos_spec.rb +9 -0
  346. data/spec/integration/core/stat/debian_spec.rb +9 -0
  347. data/spec/integration/core/stat/fedora_spec.rb +9 -0
  348. data/spec/integration/core/stat/opensuse_spec.rb +9 -0
  349. data/spec/integration/core/stat/rhel_spec.rb +9 -0
  350. data/spec/integration/core/stat/sles_spec.rb +9 -0
  351. data/spec/integration/core/stat/ubuntu_spec.rb +9 -0
  352. data/spec/integration/core/stream/centos_spec.rb +9 -0
  353. data/spec/integration/core/stream/debian_spec.rb +9 -0
  354. data/spec/integration/core/stream/fedora_spec.rb +9 -0
  355. data/spec/integration/core/stream/opensuse_spec.rb +9 -0
  356. data/spec/integration/core/stream/rhel_spec.rb +9 -0
  357. data/spec/integration/core/stream/sles_spec.rb +9 -0
  358. data/spec/integration/core/stream/ubuntu_spec.rb +9 -0
  359. data/spec/integration/core/system/centos_spec.rb +9 -0
  360. data/spec/integration/core/system/debian_spec.rb +9 -0
  361. data/spec/integration/core/system/fedora_spec.rb +9 -0
  362. data/spec/integration/core/system/opensuse_spec.rb +9 -0
  363. data/spec/integration/core/system/rhel_spec.rb +9 -0
  364. data/spec/integration/core/system/sles_spec.rb +9 -0
  365. data/spec/integration/core/system/ubuntu_spec.rb +9 -0
  366. data/spec/integration/core/transfer/centos_spec.rb +9 -0
  367. data/spec/integration/core/transfer/debian_spec.rb +9 -0
  368. data/spec/integration/core/transfer/fedora_spec.rb +9 -0
  369. data/spec/integration/core/transfer/opensuse_spec.rb +9 -0
  370. data/spec/integration/core/transfer/rhel_spec.rb +9 -0
  371. data/spec/integration/core/transfer/sles_spec.rb +9 -0
  372. data/spec/integration/core/transfer/ubuntu_spec.rb +9 -0
  373. data/spec/integration/core/user/centos_spec.rb +9 -0
  374. data/spec/integration/core/user/debian_spec.rb +9 -0
  375. data/spec/integration/core/user/fedora_spec.rb +9 -0
  376. data/spec/integration/core/user/opensuse_spec.rb +9 -0
  377. data/spec/integration/core/user/rhel_spec.rb +9 -0
  378. data/spec/integration/core/user/sles_spec.rb +9 -0
  379. data/spec/integration/core/user/ubuntu_spec.rb +9 -0
  380. data/spec/integration/core/yum/centos_spec.rb +9 -0
  381. data/spec/integration/core/yum/fedora_spec.rb +9 -0
  382. data/spec/integration/core/yum/rhel_spec.rb +9 -0
  383. data/spec/integration/core/zypper/opensuse_spec.rb +9 -0
  384. data/spec/integration/core/zypper/sles_spec.rb +9 -0
  385. data/spec/integration/remote/cluster/ubuntu_spec.rb +9 -0
  386. data/spec/integration/remote/cpu/centos_spec.rb +9 -0
  387. data/spec/integration/remote/cpu/debian_spec.rb +9 -0
  388. data/spec/integration/remote/cpu/fedora_spec.rb +9 -0
  389. data/spec/integration/remote/cpu/opensuse_spec.rb +9 -0
  390. data/spec/integration/remote/cpu/rhel_spec.rb +9 -0
  391. data/spec/integration/remote/cpu/sles_spec.rb +9 -0
  392. data/spec/integration/remote/cpu/ubuntu_spec.rb +9 -0
  393. data/spec/integration/remote/env/centos_spec.rb +9 -0
  394. data/spec/integration/remote/env/debian_spec.rb +9 -0
  395. data/spec/integration/remote/env/fedora_spec.rb +9 -0
  396. data/spec/integration/remote/env/opensuse_spec.rb +9 -0
  397. data/spec/integration/remote/env/rhel_spec.rb +9 -0
  398. data/spec/integration/remote/env/sles_spec.rb +9 -0
  399. data/spec/integration/remote/env/ubuntu_spec.rb +9 -0
  400. data/spec/integration/remote/fstab/centos_spec.rb +9 -0
  401. data/spec/integration/remote/fstab/debian_spec.rb +9 -0
  402. data/spec/integration/remote/fstab/fedora_spec.rb +9 -0
  403. data/spec/integration/remote/fstab/opensuse_spec.rb +9 -0
  404. data/spec/integration/remote/fstab/rhel_spec.rb +9 -0
  405. data/spec/integration/remote/fstab/sles_spec.rb +9 -0
  406. data/spec/integration/remote/fstab/ubuntu_spec.rb +9 -0
  407. data/spec/integration/remote/host/centos_spec.rb +9 -0
  408. data/spec/integration/remote/host/debian_spec.rb +9 -0
  409. data/spec/integration/remote/host/fedora_spec.rb +9 -0
  410. data/spec/integration/remote/host/opensuse_spec.rb +9 -0
  411. data/spec/integration/remote/host/rhel_spec.rb +9 -0
  412. data/spec/integration/remote/host/sles_spec.rb +9 -0
  413. data/spec/integration/remote/host/ubuntu_spec.rb +9 -0
  414. data/spec/integration/remote/memory/centos_spec.rb +9 -0
  415. data/spec/integration/remote/memory/debian_spec.rb +9 -0
  416. data/spec/integration/remote/memory/fedora_spec.rb +9 -0
  417. data/spec/integration/remote/memory/opensuse_spec.rb +9 -0
  418. data/spec/integration/remote/memory/rhel_spec.rb +9 -0
  419. data/spec/integration/remote/memory/sles_spec.rb +9 -0
  420. data/spec/integration/remote/memory/ubuntu_spec.rb +9 -0
  421. data/spec/integration/remote/os/centos_spec.rb +9 -0
  422. data/spec/integration/remote/os/debian_spec.rb +9 -0
  423. data/spec/integration/remote/os/fedora_spec.rb +9 -0
  424. data/spec/integration/remote/os/opensuse_spec.rb +9 -0
  425. data/spec/integration/remote/os/rhel_spec.rb +9 -0
  426. data/spec/integration/remote/os/sles_spec.rb +9 -0
  427. data/spec/integration/remote/os/ubuntu_spec.rb +9 -0
  428. data/spec/integration/remote/remote_file/centos_spec.rb +9 -0
  429. data/spec/integration/remote/remote_file/debian_spec.rb +9 -0
  430. data/spec/integration/remote/remote_file/fedora_spec.rb +9 -0
  431. data/spec/integration/remote/remote_file/opensuse_spec.rb +9 -0
  432. data/spec/integration/remote/remote_file/rhel_spec.rb +9 -0
  433. data/spec/integration/remote/remote_file/sles_spec.rb +9 -0
  434. data/spec/integration/remote/remote_file/ubuntu_spec.rb +9 -0
  435. data/spec/spec_helper.rb +2 -11
  436. data/spec/support/shared_examples/integration/core/apt.rb +117 -0
  437. data/spec/support/shared_examples/integration/core/archive.rb +221 -0
  438. data/spec/support/shared_examples/integration/core/disk.rb +91 -0
  439. data/spec/support/shared_examples/integration/core/dmi.rb +34 -0
  440. data/spec/support/shared_examples/integration/core/file.rb +357 -0
  441. data/spec/support/shared_examples/integration/core/find.rb +50 -0
  442. data/spec/support/shared_examples/integration/core/group.rb +62 -0
  443. data/spec/support/shared_examples/integration/core/ip.rb +68 -0
  444. data/spec/support/shared_examples/integration/core/path.rb +90 -0
  445. data/spec/support/shared_examples/integration/core/socket.rb +27 -0
  446. data/spec/support/shared_examples/integration/core/stat.rb +95 -0
  447. data/spec/support/shared_examples/integration/core/stream.rb +112 -0
  448. data/spec/support/shared_examples/integration/core/system.rb +155 -0
  449. data/spec/support/shared_examples/integration/core/transfer.rb +101 -0
  450. data/spec/support/shared_examples/integration/core/user.rb +72 -0
  451. data/spec/support/shared_examples/integration/core/yum.rb +115 -0
  452. data/spec/support/shared_examples/integration/core/zypper.rb +196 -0
  453. data/spec/{integration/remote/cluster_spec.rb → support/shared_examples/integration/remote/cluster.rb} +2 -2
  454. data/spec/support/shared_examples/integration/remote/cpu.rb +38 -0
  455. data/spec/support/shared_examples/integration/remote/env_spec.rb +33 -0
  456. data/spec/support/shared_examples/integration/remote/fstab.rb +89 -0
  457. data/spec/support/shared_examples/integration/remote/host.rb +65 -0
  458. data/spec/support/shared_examples/integration/remote/memory.rb +27 -0
  459. data/spec/support/shared_examples/integration/remote/os.rb +60 -0
  460. data/spec/support/shared_examples/integration/remote/remote_file.rb +172 -0
  461. data/spec/unit/command_spec.rb +2 -0
  462. data/spec/unit/core/ip_spec.rb +12 -0
  463. data/spec/unit/util_spec.rb +16 -0
  464. metadata +436 -31
  465. data/spec/integration/core/apt_spec.rb +0 -119
  466. data/spec/integration/core/archive_spec.rb +0 -223
  467. data/spec/integration/core/disk_spec.rb +0 -93
  468. data/spec/integration/core/dmi_spec.rb +0 -36
  469. data/spec/integration/core/file_spec.rb +0 -359
  470. data/spec/integration/core/find_spec.rb +0 -52
  471. data/spec/integration/core/group_spec.rb +0 -64
  472. data/spec/integration/core/ip_spec.rb +0 -70
  473. data/spec/integration/core/path_spec.rb +0 -92
  474. data/spec/integration/core/socket_spec.rb +0 -29
  475. data/spec/integration/core/stat_spec.rb +0 -97
  476. data/spec/integration/core/stream_spec.rb +0 -114
  477. data/spec/integration/core/system_spec.rb +0 -142
  478. data/spec/integration/core/transfer_spec.rb +0 -103
  479. data/spec/integration/core/user_spec.rb +0 -74
  480. data/spec/integration/core/yum_spec.rb +0 -117
  481. data/spec/integration/core/zypper_spec.rb +0 -198
  482. data/spec/integration/remote/cpu_spec.rb +0 -40
  483. data/spec/integration/remote/env_spec.rb +0 -35
  484. data/spec/integration/remote/fstab_spec.rb +0 -91
  485. data/spec/integration/remote/host_spec.rb +0 -67
  486. data/spec/integration/remote/memory_spec.rb +0 -29
  487. data/spec/integration/remote/os_spec.rb +0 -62
  488. data/spec/integration/remote/remote_file_spec.rb +0 -174
  489. data/spec/zz_reboot_spec.rb +0 -46
@@ -0,0 +1,814 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::IP do
6
+ before(:all) do
7
+ StubNetwork.stub!
8
+ end
9
+
10
+ after(:all) do
11
+ StubNetwork.unstub!
12
+ end
13
+
14
+ let(:host) do
15
+ Kanrisuru::Remote::Host.new(
16
+ host: 'localhost',
17
+ username: 'ubuntu',
18
+ keys: ['id_rsa']
19
+ )
20
+ end
21
+
22
+ %w[link l].each do |object_variant|
23
+ context "with ip #{object_variant}" do
24
+ context 'with json support' do
25
+ before(:all) do
26
+ StubNetwork.stub_command!(:ip_version) do
27
+ Kanrisuru::Core::IP::IPROUTE2_JSON_VERSION
28
+ end
29
+ end
30
+
31
+ after(:all) do
32
+ StubNetwork.unstub_command!(:ip_version)
33
+ end
34
+
35
+ %w[show list].each do |action_variant|
36
+ it "prepares #{action_variant} command" do
37
+ expect_command(host.ip(object_variant, action_variant), 'ip -json link show')
38
+ expect_command(host.ip(object_variant, action_variant, {
39
+ stats: true,
40
+ family: 'inet',
41
+ dev: 'eth0',
42
+ up: true
43
+ }), 'ip -json -s -family inet link show dev eth0 up')
44
+
45
+ expect_command(host.ip(object_variant, action_variant, {
46
+ dev: 'eth0.10',
47
+ group: '0',
48
+ master: 'eth0',
49
+ vrf: 'red',
50
+ type: 'vlan'
51
+ }), 'ip -json link show dev eth0.10 group 0 master eth0 type vlan vrf red')
52
+ end
53
+ end
54
+ end
55
+
56
+ context 'without json support' do
57
+ before(:all) do
58
+ StubNetwork.stub_command!(:ip_version) do
59
+ Kanrisuru::Core::IP::IPROUTE2_JSON_VERSION - 1
60
+ end
61
+ end
62
+
63
+ after(:all) do
64
+ StubNetwork.unstub_command!(:ip_version)
65
+ end
66
+
67
+ %w[show list].each do |action_variant|
68
+ it "prepares #{action_variant} command" do
69
+ expect_command(host.ip(object_variant, action_variant), 'ip link show')
70
+ expect_command(host.ip(object_variant, action_variant, {
71
+ stats: true,
72
+ family: 'inet',
73
+ dev: 'eth0',
74
+ up: true
75
+ }), 'ip -s -family inet link show dev eth0 up')
76
+
77
+ expect_command(host.ip(object_variant, action_variant, {
78
+ dev: 'eth0.10',
79
+ group: '0',
80
+ master: 'eth0',
81
+ vrf: 'red',
82
+ type: 'vlan'
83
+ }), 'ip link show dev eth0.10 group 0 master eth0 type vlan vrf red')
84
+ end
85
+ end
86
+ end
87
+
88
+ %w[delete del].each do |action_variant|
89
+ it "prepares #{action_variant} command" do
90
+ expect_command(host.ip(object_variant, action_variant, {
91
+ dev: 'eth2'
92
+ }), 'ip link delete dev eth2')
93
+
94
+ expect_command(host.ip(object_variant, action_variant, {
95
+ group: '0'
96
+ }), 'ip link delete group 0')
97
+
98
+ expect_command(host.ip(object_variant, action_variant, {
99
+ type: 'vxlan'
100
+ }), 'ip link delete type vxlan')
101
+ end
102
+ end
103
+
104
+ %w[add a].each do |action_variant|
105
+ it "prepares #{action_variant} command" do
106
+ expect_command(host.ip(object_variant, action_variant, {
107
+ dev: 'eth0',
108
+ name: 'eth0',
109
+ mtu: 9000,
110
+ index: 1,
111
+ numttxqueues: 1000,
112
+ numrxqueues: 1000,
113
+ gso_max_size: 32,
114
+ gso_max_segs: 64
115
+ }), 'ip link add dev eth0 name eth0 mtu 9000 index 1 numrxqueues 1000 gso_max_size 32 gso_max_segs 64')
116
+ end
117
+
118
+ it "prepares #{action_variant} command with vlan" do
119
+ expect_command(host.ip(object_variant, action_variant, {
120
+ dev: 'eth0',
121
+ name: 'eth0.10',
122
+ type: 'vlan',
123
+ type_opts: {
124
+ id: 10,
125
+ protocol: '802.1Q',
126
+ reorder_hdr: 'off',
127
+ gvrp: 'off',
128
+ mvrp: 'on',
129
+ loose_binding: 'on',
130
+ ingress_qos_map: '1:2',
131
+ egress_qos_map: '2:1'
132
+ }
133
+ }), 'ip link add dev eth0 name eth0.10 type vlan protocol 802.1Q id 10 reorder_hdr off gvrp off mvrp on loose_binding on ingress-qos-map 1:2 egress-qos-map 2:1')
134
+ end
135
+
136
+ it "prepares #{action_variant} command with vxlan" do
137
+ expect_command(host.ip(object_variant, action_variant, {
138
+ name: 'eth0.5',
139
+ type: 'vxlan',
140
+ type_opts: {
141
+ id: 5,
142
+ remote: '172.0.0.12',
143
+ dev: 'eth0',
144
+ local: '10.0.0.1',
145
+ ttl: '300',
146
+ tos: '0x28',
147
+ df: 'set',
148
+ flowlabel: 'vxlan-label',
149
+ dstport: 6082,
150
+ srcport: '6085 6086',
151
+ learning: true,
152
+ rsc: true,
153
+ proxy: true,
154
+ l2miss: true,
155
+ l3miss: true,
156
+ external: true,
157
+ udpcsum: true,
158
+ udp6zerocsumtx: true,
159
+ udp6zerocsumrx: true,
160
+ ageing: 3600,
161
+ maxaddress: 128,
162
+ gbp: true,
163
+ gpe: true
164
+ }
165
+ }), 'ip link add name eth0.5 type vxlan id 5 dev eth0 remote 172.0.0.12 local 10.0.0.1 ttl 300 tos 0x28 df set flowlabel vxlan-label dstport 6082 srcport 6085 6086 learning rsc proxy l2miss l3miss udpcsum udp6zerocsumtx udp6zerocsumrx ageing 3600 maxaddress 128 gbp gpe')
166
+
167
+ expect_command(host.ip(object_variant, action_variant, {
168
+ name: 'eth0.5',
169
+ type: 'vxlan',
170
+ type_opts: {
171
+ id: 5,
172
+ remote: '172.0.0.12',
173
+ dev: 'eth0',
174
+ learning: false,
175
+ rsc: false,
176
+ proxy: false,
177
+ l2miss: false,
178
+ l3miss: false,
179
+ external: false,
180
+ udpcsum: false,
181
+ udp6zerocsumtx: false,
182
+ udp6zerocsumrx: false,
183
+ gbp: false
184
+ }
185
+ }), 'ip link add name eth0.5 type vxlan id 5 dev eth0 remote 172.0.0.12 nolearning norsc noproxy nol2miss nol3miss noudpcsum noudp6zerocsumtx noudp6zerocsumrx')
186
+ end
187
+
188
+ it "prepares #{action_variant} command with veth" do
189
+ expect_command(host.ip(object_variant, action_variant, {
190
+ dev: 'eth0',
191
+ name: 'eth0.10',
192
+ type: 'veth',
193
+ type_opts: {
194
+ peer_name: 'veth-tunnel-connect'
195
+ }
196
+ }), 'ip link add dev eth0 name eth0.10 type veth peer name veth-tunnel-connect')
197
+ end
198
+
199
+ it "prepares #{action_variant} command with vxcan" do
200
+ expect_command(host.ip(object_variant, action_variant, {
201
+ dev: 'eth0',
202
+ name: 'eth0.10',
203
+ type: 'vxcan',
204
+ type_opts: {
205
+ peer_name: 'vxcan-tunnel-connect'
206
+ }
207
+ }), 'ip link add dev eth0 name eth0.10 type vxcan peer name vxcan-tunnel-connect')
208
+ end
209
+
210
+ %w[ipip sit].each do |type|
211
+ it "prepares #{action_variant} command with #{type}" do
212
+ expect_command(host.ip(object_variant, action_variant, {
213
+ dev: 'eth0',
214
+ name: 'eth0.10',
215
+ type: type,
216
+ type_opts: {
217
+ remote: '172.0.0.1',
218
+ local: '10.0.0.2',
219
+ encap: 'gue',
220
+ encap_support: 'auto',
221
+ encap_csum: true,
222
+ encap_remcsum: true,
223
+ mode: 'any',
224
+ external: true
225
+ }
226
+ }), "ip link add dev eth0 name eth0.10 type #{type} remote 172.0.0.1 local 10.0.0.2 encap gue encap-csum encap-remcsum external mode any")
227
+
228
+ expect_command(host.ip(object_variant, action_variant, {
229
+ dev: 'eth0',
230
+ name: 'eth0.10',
231
+ type: type,
232
+ type_opts: {
233
+ remote: '172.0.0.1',
234
+ local: '10.0.0.2',
235
+ encap: 'gue',
236
+ encap_support: 'auto',
237
+ encap_csum: false,
238
+ encap_remcsum: false,
239
+ mode: 'any'
240
+ }
241
+ }), "ip link add dev eth0 name eth0.10 type #{type} remote 172.0.0.1 local 10.0.0.2 encap gue noencap-csum noencap-remcsum mode any")
242
+ end
243
+ end
244
+
245
+ %w[gre gretap].each do |type|
246
+ it "prepares #{action_variant} command with #{type}" do
247
+ expect_command(host.ip(object_variant, action_variant, {
248
+ name: 'eth0.10',
249
+ type: type,
250
+ type_opts: {
251
+ remote: '172.0.0.1',
252
+ local: '10.0.0.2',
253
+ iseq: true,
254
+ oseq: true,
255
+ icsum: true,
256
+ ocsum: true,
257
+ ikey: 10,
258
+ okey: 10,
259
+ ttl: 300,
260
+ tos: '0x28',
261
+ pmtudisc: true,
262
+ ignore_df: true,
263
+ dev: 'eth0',
264
+ encap: 'none',
265
+ encap_sport: 'auto',
266
+ encap_csum: true,
267
+ encap_remcsum: true,
268
+ external: true
269
+ }
270
+ }), "ip link add name eth0.10 type #{type} remote 172.0.0.1 local 10.0.0.2 encap none encap-sport auto encap-csum encap-remcsum external iseq oseq icsum ocsum okey 10 ikey 10 ttl 300 tos 0x28 pmtudisc ignore-df dev eth0")
271
+
272
+ expect_command(host.ip(object_variant, action_variant, {
273
+ name: 'eth0.10',
274
+ type: type,
275
+ type_opts: {
276
+ remote: '172.0.0.1',
277
+ local: '10.0.0.2',
278
+ iseq: false,
279
+ oseq: false,
280
+ icsum: false,
281
+ ocsum: false,
282
+ ikey: false,
283
+ okey: false,
284
+ tos: '0x28',
285
+ pmtudisc: false,
286
+ ignore_df: false,
287
+ dev: 'eth0',
288
+ encap: 'none',
289
+ encap_sport: 'auto',
290
+ encap_csum: false,
291
+ encap_remcsum: false
292
+ }
293
+ }), "ip link add name eth0.10 type #{type} remote 172.0.0.1 local 10.0.0.2 encap none encap-sport auto noencap-csum noencap-remcsum noiseq nooseq noicsum noocsum tos 0x28 nopmtudisc noignore-df dev eth0")
294
+ end
295
+ end
296
+
297
+ %w[ip6gre ip6gretap].each do |type|
298
+ it "prepares #{action_variant} command with #{type}" do
299
+ expect_command(host.ip(object_variant, action_variant, {
300
+ dev: 'eth0',
301
+ name: 'eth0.10',
302
+ type: type,
303
+ type_opts: {
304
+ external: true
305
+ }
306
+ }), "ip link add dev eth0 name eth0.10 type #{type} external true")
307
+
308
+ expect_command(host.ip(object_variant, action_variant, {
309
+ dev: 'eth0',
310
+ name: 'eth0.10',
311
+ type: type,
312
+ type_opts: {
313
+ remote: '172.0.0.1',
314
+ local: '10.0.0.3',
315
+ iseq: true,
316
+ oseq: true,
317
+ icsum: true,
318
+ ocsum: true,
319
+ ikey: 10,
320
+ okey: 10,
321
+ hoplimit: 300,
322
+ encaplimit: 5,
323
+ flowlabel: 'gre-flow-label',
324
+ allow_localremote: true,
325
+ tclass: 'internet'
326
+ }
327
+ }), "ip link add dev eth0 name eth0.10 type #{type} remote 172.0.0.1 local 10.0.0.3 iseq oseq icsum ocsum okey 10 ikey 10 hoplimit 300 encaplimit 5 flowlabel gre-flow-label allow-localremote tclass internet")
328
+
329
+ expect_command(host.ip(object_variant, action_variant, {
330
+ dev: 'eth0',
331
+ name: 'eth0.10',
332
+ type: type,
333
+ type_opts: {
334
+ remote: '172.0.0.1',
335
+ local: '10.0.0.3',
336
+ iseq: false,
337
+ oseq: false,
338
+ icsum: false,
339
+ ocsum: false,
340
+ ikey: false,
341
+ okey: false,
342
+ allow_localremote: false
343
+ }
344
+ }), "ip link add dev eth0 name eth0.10 type #{type} remote 172.0.0.1 local 10.0.0.3 noiseq nooseq noicsum noocsum noallow-localremote")
345
+ end
346
+ end
347
+
348
+ it "prepares #{action_variant} command with ipoib" do
349
+ expect_command(host.ip(object_variant, action_variant, {
350
+ dev: 'eth0',
351
+ name: 'eth0.10',
352
+ type: 'ipoib',
353
+ type_opts: {
354
+ pkey: '0x8003',
355
+ mode: 'connected'
356
+ }
357
+ }), 'ip link add dev eth0 name eth0.10 type ipoib pkey 0x8003 mode connected')
358
+ end
359
+
360
+ it "prepares #{action_variant} command with erspan" do
361
+ expect_command(host.ip(object_variant, action_variant, {
362
+ dev: 'erspan1',
363
+ name: 'erspan1',
364
+ type: 'erspan',
365
+ type_opts: {
366
+ remote: '172.0.0.1',
367
+ local: '10.0.0.4',
368
+ erspan_ver: 2,
369
+ erspan: '1',
370
+ erspan_dir: 'ingress',
371
+ erspan_hwid: '17',
372
+ allow_localremote: true
373
+ }
374
+ }), 'ip link add dev erspan1 name erspan1 type erspan remote 172.0.0.1 local 10.0.0.4 erspan_ver 2 erspan 1 erspan_dir ingress erspan_hwid 17 allow-localremote')
375
+
376
+ expect_command(host.ip(object_variant, action_variant, {
377
+ dev: 'erspan2',
378
+ name: 'erspan2',
379
+ type: 'erspan',
380
+ type_opts: {
381
+ remote: '172.0.0.1',
382
+ local: '10.0.0.4',
383
+ allow_localremote: false
384
+ }
385
+ }), 'ip link add dev erspan2 name erspan2 type erspan remote 172.0.0.1 local 10.0.0.4 noallow-localremote')
386
+
387
+ expect_command(host.ip(object_variant, action_variant, {
388
+ dev: 'erspan3',
389
+ name: 'erspan3',
390
+ type: 'erspan',
391
+ type_opts: {
392
+ external: true
393
+ }
394
+ }), 'ip link add dev erspan3 name erspan3 type erspan external')
395
+ end
396
+
397
+ it "prepares #{action_variant} command with ip6erspan" do
398
+ expect_command(host.ip(object_variant, action_variant, {
399
+ dev: 'ip6erspan1',
400
+ name: 'ip6erspan1',
401
+ type: 'ip6erspan',
402
+ type_opts: {
403
+ remote: 'fc00:100::1',
404
+ local: 'fc00:100::1',
405
+ erspan_ver: 2,
406
+ erspan: '1',
407
+ erspan_dir: 'ingress',
408
+ erspan_hwid: '17',
409
+ allow_localremote: true
410
+ }
411
+ }), 'ip link add dev ip6erspan1 name ip6erspan1 type ip6erspan remote fc00:100::1 local fc00:100::1 erspan_ver 2 erspan 1 erspan_dir ingress erspan_hwid 17 allow-localremote')
412
+
413
+ expect_command(host.ip(object_variant, action_variant, {
414
+ dev: 'ip6erspan2',
415
+ name: 'ip6erspan2',
416
+ type: 'ip6erspan',
417
+ type_opts: {
418
+ remote: 'fc00:100::1',
419
+ local: 'fc00:100::1',
420
+ allow_localremote: false
421
+ }
422
+ }), 'ip link add dev ip6erspan2 name ip6erspan2 type ip6erspan remote fc00:100::1 local fc00:100::1 noallow-localremote')
423
+
424
+ expect_command(host.ip(object_variant, action_variant, {
425
+ dev: 'ip6erspan3',
426
+ name: 'ip6erspan3',
427
+ type: 'ip6erspan',
428
+ type_opts: {
429
+ external: true
430
+ }
431
+ }), 'ip link add dev ip6erspan3 name ip6erspan3 type ip6erspan external')
432
+ end
433
+
434
+ it "prepares #{action_variant} command with geneve" do
435
+ expect_command(host.ip(object_variant, action_variant, {
436
+ dev: 'eth0',
437
+ name: 'geneve0',
438
+ type: 'geneve',
439
+ type_opts: {
440
+ external: true
441
+ }
442
+ }), 'ip link add dev eth0 name geneve0 type geneve external')
443
+
444
+ expect_command(host.ip(object_variant, action_variant, {
445
+ dev: 'eth0',
446
+ name: 'geneve0',
447
+ type: 'geneve',
448
+ type_opts: {
449
+ external: false
450
+ }
451
+ }), 'ip link add dev eth0 name geneve0 type geneve noexternal')
452
+
453
+ expect_command(host.ip(object_variant, action_variant, {
454
+ dev: 'eth0',
455
+ name: 'geneve0',
456
+ type: 'geneve',
457
+ type_opts: {
458
+ id: 1,
459
+ remote: '172.0.0.1',
460
+ ttl: 300,
461
+ tos: '0x28',
462
+ df: 'unset',
463
+ flowlabel: 'geneve-flow-label',
464
+ dstport: 6082,
465
+ udpcsum: true,
466
+ udp6zerocsumtx: true,
467
+ udp6zerocsumrx: true
468
+ }
469
+ }), 'ip link add dev eth0 name geneve0 type geneve id 1 remote 172.0.0.1 ttl 300 tos 0x28 df unset flowlabel geneve-flow-label dstport 6082 udpcsum udp6zerocsumtx udp6zerocsumrx')
470
+
471
+ expect_command(host.ip(object_variant, action_variant, {
472
+ dev: 'eth0',
473
+ name: 'geneve0',
474
+ type: 'geneve',
475
+ type_opts: {
476
+ id: 1,
477
+ remote: '172.0.0.1',
478
+ ttl: 300,
479
+ tos: '0x28',
480
+ df: 'unset',
481
+ flowlabel: 'geneve-flow-label',
482
+ dstport: 6082,
483
+ udpcsum: false,
484
+ udp6zerocsumtx: false,
485
+ udp6zerocsumrx: false
486
+ }
487
+ }), 'ip link add dev eth0 name geneve0 type geneve id 1 remote 172.0.0.1 ttl 300 tos 0x28 df unset flowlabel geneve-flow-label dstport 6082 noudpcsum noudp6zerocsumtx noudp6zerocsumrx')
488
+ end
489
+
490
+ it "prepares #{action_variant} command with bareudp" do
491
+ expect_command(host.ip(object_variant, action_variant, {
492
+ dev: 'bareudp0',
493
+ name: 'bareudp0',
494
+ type: 'bareudp',
495
+ type_opts: {
496
+ dstport: 6635,
497
+ ethertype: 'mpls_uc',
498
+ srcportmin: 100,
499
+ multiproto: true
500
+ }
501
+ }), 'ip link add dev bareudp0 name bareudp0 type bareudp dstport 6635 ethertype mpls_uc srcportmin 100 multiproto')
502
+ end
503
+
504
+ %w[macvlan macvtap].each do |type|
505
+ it "prepares #{action_variant} command with #{type}" do
506
+ expect_command(host.ip(object_variant, action_variant, {
507
+ dev: 'bareudp0',
508
+ name: 'bareudp0',
509
+ type: type,
510
+ type_opts: {
511
+ mode: 'bridge'
512
+ }
513
+ }), "ip link add dev bareudp0 name bareudp0 type #{type} mode bridge")
514
+ end
515
+ end
516
+
517
+ it "prepares #{action_variant} command with hsr" do
518
+ expect_command(host.ip(object_variant, action_variant, {
519
+ dev: 'hsr1',
520
+ name: 'hsr1',
521
+ type: 'hsr',
522
+ type_opts: {
523
+ slave1: 'eth1',
524
+ slave2: 'eth2',
525
+ supervision: '254',
526
+ version: '1',
527
+ proto: '1'
528
+ }
529
+ }), 'ip link add dev hsr1 name hsr1 type hsr slave1 eth1 slave2 eth2 supervision 254 version 1 proto 1')
530
+ end
531
+
532
+ it "prepares #{action_variant} command with bridge" do
533
+ expect_command(host.ip(object_variant, action_variant, {
534
+ dev: 'br0',
535
+ name: 'br0',
536
+ type: 'bridge',
537
+ type_opts: {
538
+ ageing_time: 29_999,
539
+ group_fwd_mask: 0,
540
+ group_address: '01:80:c2:00:00:00',
541
+ forward_delay: 0,
542
+ hello_time: 199,
543
+ max_age: 1999,
544
+ stp_state: 0,
545
+ priority: 32_768,
546
+ vlan_filtering: 0,
547
+ vlan_protocol: '802.1Q',
548
+ vlan_default_pvid: 1,
549
+ vlan_stats_enabled: 1,
550
+ vlan_stats_per_port: 1,
551
+ mcast_snooping: 1,
552
+ mcast_router: 1,
553
+ mcast_query_use_ifaddr: 0,
554
+ mcast_querier: 0,
555
+ mcast_hash_elasticity: 4,
556
+ mcast_hash_max: 512,
557
+ mcast_last_member_count: 2,
558
+ mcast_startup_query_count: 2,
559
+ mcast_last_member_interval: 99,
560
+ mcast_membership_interval: 25_999,
561
+ mcast_querier_interval: 25_499,
562
+ mcast_query_interval: 12_499,
563
+ mcast_query_response_interval: 999,
564
+ mcast_startup_query_interval: 3124,
565
+ mcast_stats_enabled: 0,
566
+ mcast_igmp_version: 2,
567
+ mcast_mld_version: 1,
568
+ nf_call_iptables: 0,
569
+ nf_call_ip6tables: 0,
570
+ nf_call_arptables: 0
571
+ }
572
+ }), 'ip link add dev br0 name br0 type bridge ageing_time 29999 group_fwd_mask 0 group_address 01:80:c2:00:00:00 forward_delay 0 hello_time 199 max_age 1999 stp_state 0 priority 32768 vlan_filtering 0 vlan_protocol 802.1Q vlan_default_pvid 1 vlan_stats_enabled 1 vlan_stats_per_port 1 mcast_snooping 1 mcast_router 1 mcast_query_use_ifaddr 0 mcast_querier 0 mcast_querier_interval 25499 mcast_hash_elasticity 4 mcast_hash_max 512 mcast_last_member_count 2 mcast_last_member_interval 99 mcast_startup_query_count 2 mcast_startup_query_interval 3124 mcast_query_interval 12499 mcast_query_response_interval 999 mcast_membership_interval 25999 mcast_stats_enabled 0 mcast_igmp_version 2 mcast_mld_version 1 nf_call_iptables 0 nf_call_ip6tables 0 nf_call_arptables 0')
573
+ end
574
+
575
+ it "prepares #{action_variant} command with macsec" do
576
+ expect_command(host.ip(object_variant, action_variant, {
577
+ dev: 'eth0',
578
+ name: 'macsec0',
579
+ type: 'macsec',
580
+ type_opts: {
581
+ address: '32:53:41:bd:7c:27',
582
+ port: 11,
583
+ send_sci: 'on',
584
+ sci: '1',
585
+ cipher: 'GCM-AES-128',
586
+ icvlen: 16,
587
+ encrypt: 'on',
588
+ end_station: 'on',
589
+ scb: 'on',
590
+ protect: 'on',
591
+ replay: 'on',
592
+ window: 1,
593
+ validate: 'check',
594
+ encodingsa: '3'
595
+ }
596
+ }), 'ip link add dev eth0 name macsec0 type macsec address 32:53:41:bd:7c:27 port 11 sci 1 cipher GCM-AES-128 icvlen 16 encrypt on send_sci on end_station on scb on protect on replay on window 1 validate check encodingsa 3')
597
+ end
598
+
599
+ it "prepares #{action_variant} command with vrf" do
600
+ expect_command(host.ip(object_variant, action_variant, {
601
+ dev: 'vrf1',
602
+ name: 'vrf1',
603
+ type: 'vrf',
604
+ type_opts: {
605
+ table: 10
606
+ }
607
+ }), 'ip link add dev vrf1 name vrf1 type vrf table 10')
608
+ end
609
+
610
+ it "prepares #{action_variant} command with rmnet" do
611
+ expect_command(host.ip(object_variant, action_variant, {
612
+ dev: 'rmnet0',
613
+ name: 'rmnet0',
614
+ type: 'rmnet',
615
+ type_opts: {
616
+ mux_id: 254
617
+ }
618
+ }), 'ip link add dev rmnet0 name rmnet0 type rmnet mux_id 254')
619
+ end
620
+
621
+ it "prepares #{action_variant} command with xfrm" do
622
+ expect_command(host.ip(object_variant, action_variant, {
623
+ name: 'xfrm3',
624
+ type: 'xfrm',
625
+ type_opts: {
626
+ dev: 'xfrm3',
627
+ if_id: 0
628
+ }
629
+ }), 'ip link add name xfrm3 type xfrm if_id 0')
630
+ end
631
+ end
632
+
633
+ it 'prepares set command' do
634
+ expect_command(host.ip(object_variant, 'set', {
635
+ dev: 'eth10.10',
636
+ direction: 'down'
637
+ }), 'ip link set dev eth10.10 down')
638
+
639
+ expect_command(host.ip(object_variant, 'set', {
640
+ dev: 'eno1.10',
641
+ mtu: 1400,
642
+ direction: 'up',
643
+ arp: 'on',
644
+ multicast: 'on',
645
+ allmulticast: 'on',
646
+ promisc: 'on',
647
+ trailers: 'on',
648
+ protodown: 'on',
649
+ protodown_reason: 30,
650
+ dynamic: 'on',
651
+ name: 'eno1-vlan.10',
652
+ txqueuelen: 256,
653
+ txqlen: 4,
654
+ master: 'eno1',
655
+ address: '172.16.0.2',
656
+ broadcast: 'ff:ff:ff:ff:ff:ff',
657
+ brd: 'ff:ff:ff:ff:ff:ff',
658
+ peer: 'ae:14:7e:e4:6c:64',
659
+ netns: 1154,
660
+ alias: 'eno1-alias',
661
+ group: 0
662
+ }), 'ip link set dev eno1.10 group 0 up arp on multicast on allmulticast on promisc on protodown on protodown_reason 30 dynamic on name eno1-vlan.10 txqueuelen 256 txqlen 4 mtu 1400 address 172.16.0.2 broadcast ff:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff peer ae:14:7e:e4:6c:64 netns 1154 alias eno1-alias master eno1')
663
+
664
+ expect_command(host.ip(object_variant, 'set', {
665
+ dev: 'eno1.10',
666
+ master: false
667
+ }), 'ip link set dev eno1.10 nomaster')
668
+
669
+ expect do
670
+ host.ip(object_variant, 'set')
671
+ end.to raise_error(ArgumentError)
672
+ end
673
+
674
+ it 'prepares set command with vf' do
675
+ expect_command(host.ip(object_variant, 'set', {
676
+ dev: 'eth0',
677
+ vf: 5,
678
+ mac: 'AD:D9:01:ED:0B:13',
679
+ vlan: 10,
680
+ qos: 1,
681
+ proto: '802.1ad',
682
+ rate: 0,
683
+ max_tx_rate: 0,
684
+ min_tx_rate: 0,
685
+ spoofchk: 'on',
686
+ query_rss: 'on',
687
+ state: 'enable',
688
+ trust: 'on',
689
+ node_guid: 100,
690
+ port_guid: 100
691
+ }), 'ip link set dev eth0 vf 5 mac AD:D9:01:ED:0B:13 vlan 10 qos 1 proto 802.1ad rate 0 max_tx_rate 0 min_tx_rate 0 spoofchk on query_rss on state enable trust on node_guid 100 port_guid 100')
692
+ end
693
+
694
+ it 'prepares set command with xdp' do
695
+ expect_command(host.ip(object_variant, 'set', {
696
+ dev: 'vethcaf7146',
697
+ xdp: 'object',
698
+ object: 'udp.o',
699
+ section: 'dropper_main',
700
+ verbose: true
701
+ }), 'ip link set dev vethcaf7146 xdp object udp.o section dropper_main verbose')
702
+
703
+ expect_command(host.ip(object_variant, 'set', {
704
+ dev: 'vethcaf7146',
705
+ xdp: 'pinned',
706
+ pinned: 'udp.o'
707
+ }), 'ip link set dev vethcaf7146 xdp pinned udp.o')
708
+
709
+ expect_command(host.ip(object_variant, 'set', {
710
+ dev: 'vethcaf7146',
711
+ xdp: 'off'
712
+ }), 'ip link set dev vethcaf7146 xdp off')
713
+ end
714
+
715
+ it 'prepares set command with type opts' do
716
+ expect do
717
+ host.ip(object_variant, 'set', {
718
+ dev: 'eno10.10',
719
+ type: 'bridge_'
720
+ })
721
+ end.to raise_error(ArgumentError)
722
+
723
+ expect_command(host.ip(object_variant, 'set', {
724
+ dev: 'eth0bridge',
725
+ type: 'bridge_slave',
726
+ type_opts: {
727
+ fdb_flush: true,
728
+ state: 1,
729
+ priority: 63,
730
+ cost: 1,
731
+ guard: 'on',
732
+ hairpin: 'off',
733
+ fastleave: 'off',
734
+ root_block: 'on',
735
+ learning: 'on',
736
+ flood: 'on',
737
+ proxy_arp: 'on',
738
+ proxy_arp_wifi: 'off',
739
+ mcast_router: 3,
740
+ mcast_fast_leave: 'on',
741
+ mcast_flood: 'on',
742
+ mcast_to_unicast: 'off',
743
+ group_fwd_mask: 0,
744
+ neigh_suppress: 'on',
745
+ vlan_tunnel: 'on',
746
+ backup_port: 'eth0backup'
747
+ }
748
+ }), 'ip link set dev eth0bridge type bridge_slave fdb_flush state 1 priority 63 cost 1 guard on hairpin off fastleave off root_block on learning on flood on proxy_arp on proxy_arp_wifi off mcast_router 3 mcast_fast_leave on mcast_flood on mcast_to_unicast off group_fwd_mask 0 neigh_suppress on neigh_suppress on backup_port eth0backup')
749
+
750
+ expect_command(host.ip(object_variant, 'set', {
751
+ dev: 'eth0bridge',
752
+ type: 'bridge_slave',
753
+ type_opts: {
754
+ nobackup_port: true
755
+ }
756
+ }), 'ip link set dev eth0bridge type bridge_slave nobackup_port')
757
+
758
+ expect_command(host.ip(object_variant, 'set', {
759
+ dev: 'eth0bond',
760
+ type: 'bond_slave',
761
+ type_opts: {
762
+ queue_id: 1
763
+ }
764
+ }), 'ip link set dev eth0bond type bond_slave queue_id 1')
765
+
766
+ expect_command(host.ip(object_variant, 'set', {
767
+ dev: 'eth1macvlan',
768
+ type: 'macvlan',
769
+ type_opts: {
770
+ mode: 'bridge',
771
+ flag: 'nopromisc',
772
+ mode_opts: 'add',
773
+ mac_address: '19:18:4F:92:5E:CD'
774
+ }
775
+ }), 'ip link set dev eth1macvlan type macvlan mode bridge flag nopromisc add 19:18:4F:92:5E:CD')
776
+
777
+ expect_command(host.ip(object_variant, 'set', {
778
+ dev: 'eth1macvlan',
779
+ type: 'macvlan',
780
+ type_opts: {
781
+ mode_opts: 'del',
782
+ mac_address: '19:18:4F:92:5E:CD'
783
+ }
784
+ }), 'ip link set dev eth1macvlan type macvlan del 19:18:4F:92:5E:CD')
785
+
786
+ expect_command(host.ip(object_variant, 'set', {
787
+ dev: 'eth1macvlan',
788
+ type: 'macvlan',
789
+ type_opts: {
790
+ mode_opts: 'set',
791
+ mac_address: '07:88:8C:11:C3:80'
792
+ }
793
+ }), 'ip link set dev eth1macvlan type macvlan set 07:88:8C:11:C3:80')
794
+
795
+ expect_command(host.ip(object_variant, 'set', {
796
+ dev: 'eth1macvlan',
797
+ type: 'macvtap',
798
+ type_opts: {
799
+ mode_opts: 'set',
800
+ mac_address: ['0D:42:6D:3E:22:B8', '7F:3D:FC:AF:A3:F3']
801
+ }
802
+ }), 'ip link set dev eth1macvlan type macvtap set 0D:42:6D:3E:22:B8 7F:3D:FC:AF:A3:F3')
803
+
804
+ expect_command(host.ip(object_variant, 'set', {
805
+ dev: 'eth1macvlan',
806
+ type: 'macvlan',
807
+ type_opts: {
808
+ mode_opts: 'flush'
809
+ }
810
+ }), 'ip link set dev eth1macvlan type macvlan flush')
811
+ end
812
+ end
813
+ end
814
+ end