knife-ionoscloud 5.1.1 → 6.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (326) hide show
  1. checksums.yaml +4 -4
  2. data/docs/README.md +1 -1
  3. data/docs/subcommands/composite_server_create.md +9 -3
  4. data/docs/subcommands/cube_server_create.md +91 -0
  5. data/docs/subcommands/firewall_create.md +5 -2
  6. data/docs/subcommands/flowlog_create.md +63 -0
  7. data/docs/subcommands/flowlog_delete.md +51 -0
  8. data/docs/subcommands/flowlog_list.md +51 -0
  9. data/docs/subcommands/group_create.md +10 -1
  10. data/docs/subcommands/natgateway_create.md +41 -0
  11. data/docs/subcommands/natgateway_delete.md +35 -0
  12. data/docs/subcommands/natgateway_lan_add.md +46 -0
  13. data/docs/subcommands/natgateway_lan_remove.md +39 -0
  14. data/docs/subcommands/natgateway_list.md +35 -0
  15. data/docs/subcommands/natgateway_rule_add.md +66 -0
  16. data/docs/subcommands/natgateway_rule_list.md +38 -0
  17. data/docs/subcommands/natgateway_rule_remove.md +39 -0
  18. data/docs/subcommands/networkloadbalancer_create.md +54 -0
  19. data/docs/subcommands/networkloadbalancer_delete.md +35 -0
  20. data/docs/subcommands/networkloadbalancer_list.md +35 -0
  21. data/docs/subcommands/networkloadbalancer_rule_add.md +72 -0
  22. data/docs/subcommands/networkloadbalancer_rule_list.md +39 -0
  23. data/docs/subcommands/networkloadbalancer_rule_remove.md +39 -0
  24. data/docs/subcommands/networkloadbalancer_rule_target_add.md +64 -0
  25. data/docs/subcommands/networkloadbalancer_rule_target_list.md +43 -0
  26. data/docs/subcommands/networkloadbalancer_rule_target_remove.md +51 -0
  27. data/docs/subcommands/nic_create.md +3 -3
  28. data/docs/subcommands/nodepool_lan_add.md +49 -0
  29. data/docs/subcommands/nodepool_lan_remove.md +39 -0
  30. data/docs/subcommands/server_console.md +39 -0
  31. data/docs/subcommands/server_list.md +4 -1
  32. data/docs/subcommands/server_resume.md +35 -0
  33. data/docs/subcommands/server_suspend.md +35 -0
  34. data/docs/subcommands/server_token.md +39 -0
  35. data/docs/subcommands/server_upgrade.md +39 -0
  36. data/docs/subcommands/template_list.md +31 -0
  37. data/docs/subcommands/volume_create.md +2 -5
  38. data/docs/summary.md +29 -0
  39. data/knife-ionoscloud.gemspec +1 -1
  40. data/lib/chef/knife/ionoscloud_backupunit_create.rb +12 -16
  41. data/lib/chef/knife/ionoscloud_backupunit_delete.rb +2 -5
  42. data/lib/chef/knife/ionoscloud_backupunit_get.rb +33 -0
  43. data/lib/chef/knife/ionoscloud_backupunit_list.rb +1 -1
  44. data/lib/chef/knife/ionoscloud_backupunit_ssourl.rb +1 -1
  45. data/lib/chef/knife/ionoscloud_backupunit_update.rb +62 -0
  46. data/lib/chef/knife/ionoscloud_base.rb +309 -1
  47. data/lib/chef/knife/ionoscloud_composite_server_create.rb +23 -5
  48. data/lib/chef/knife/ionoscloud_contract_list.rb +32 -23
  49. data/lib/chef/knife/ionoscloud_cube_server_create.rb +212 -0
  50. data/lib/chef/knife/ionoscloud_datacenter_create.rb +11 -14
  51. data/lib/chef/knife/ionoscloud_datacenter_delete.rb +2 -7
  52. data/lib/chef/knife/ionoscloud_datacenter_get.rb +33 -0
  53. data/lib/chef/knife/ionoscloud_datacenter_list.rb +4 -2
  54. data/lib/chef/knife/ionoscloud_datacenter_update.rb +67 -0
  55. data/lib/chef/knife/ionoscloud_firewall_create.rb +16 -21
  56. data/lib/chef/knife/ionoscloud_firewall_delete.rb +5 -13
  57. data/lib/chef/knife/ionoscloud_firewall_get.rb +52 -0
  58. data/lib/chef/knife/ionoscloud_firewall_list.rb +5 -3
  59. data/lib/chef/knife/ionoscloud_firewall_update.rb +133 -0
  60. data/lib/chef/knife/ionoscloud_flowlog_create.rb +116 -0
  61. data/lib/chef/knife/ionoscloud_flowlog_delete.rb +103 -0
  62. data/lib/chef/knife/ionoscloud_flowlog_get.rb +84 -0
  63. data/lib/chef/knife/ionoscloud_flowlog_list.rb +101 -0
  64. data/lib/chef/knife/ionoscloud_flowlog_update.rb +127 -0
  65. data/lib/chef/knife/ionoscloud_group_create.rb +33 -27
  66. data/lib/chef/knife/ionoscloud_group_delete.rb +1 -11
  67. data/lib/chef/knife/ionoscloud_group_get.rb +1 -13
  68. data/lib/chef/knife/ionoscloud_group_list.rb +19 -7
  69. data/lib/chef/knife/ionoscloud_group_update.rb +131 -0
  70. data/lib/chef/knife/ionoscloud_group_user_add.rb +1 -18
  71. data/lib/chef/knife/ionoscloud_group_user_remove.rb +1 -18
  72. data/lib/chef/knife/ionoscloud_image_list.rb +1 -1
  73. data/lib/chef/knife/ionoscloud_ipblock_create.rb +10 -13
  74. data/lib/chef/knife/ionoscloud_ipblock_delete.rb +1 -4
  75. data/lib/chef/knife/ionoscloud_ipblock_get.rb +33 -0
  76. data/lib/chef/knife/ionoscloud_ipblock_update.rb +57 -0
  77. data/lib/chef/knife/ionoscloud_ipfailover_add.rb +1 -1
  78. data/lib/chef/knife/ionoscloud_ipfailover_remove.rb +1 -1
  79. data/lib/chef/knife/ionoscloud_k8s_create.rb +27 -35
  80. data/lib/chef/knife/ionoscloud_k8s_delete.rb +1 -9
  81. data/lib/chef/knife/ionoscloud_k8s_get.rb +33 -0
  82. data/lib/chef/knife/ionoscloud_k8s_update.rb +99 -0
  83. data/lib/chef/knife/ionoscloud_label_add.rb +1 -1
  84. data/lib/chef/knife/ionoscloud_label_list.rb +1 -1
  85. data/lib/chef/knife/ionoscloud_label_remove.rb +1 -1
  86. data/lib/chef/knife/ionoscloud_lan_create.rb +6 -14
  87. data/lib/chef/knife/ionoscloud_lan_delete.rb +3 -4
  88. data/lib/chef/knife/ionoscloud_lan_get.rb +38 -0
  89. data/lib/chef/knife/ionoscloud_lan_list.rb +2 -1
  90. data/lib/chef/knife/ionoscloud_lan_update.rb +76 -0
  91. data/lib/chef/knife/ionoscloud_loadbalancer_create.rb +4 -14
  92. data/lib/chef/knife/ionoscloud_loadbalancer_delete.rb +2 -9
  93. data/lib/chef/knife/ionoscloud_loadbalancer_get.rb +3 -13
  94. data/lib/chef/knife/ionoscloud_loadbalancer_list.rb +1 -1
  95. data/lib/chef/knife/ionoscloud_loadbalancer_nic_add.rb +3 -15
  96. data/lib/chef/knife/ionoscloud_loadbalancer_nic_remove.rb +3 -16
  97. data/lib/chef/knife/ionoscloud_loadbalancer_update.rb +73 -0
  98. data/lib/chef/knife/ionoscloud_location_list.rb +5 -3
  99. data/lib/chef/knife/ionoscloud_natgateway_create.rb +60 -0
  100. data/lib/chef/knife/ionoscloud_natgateway_delete.rb +54 -0
  101. data/lib/chef/knife/ionoscloud_natgateway_get.rb +42 -0
  102. data/lib/chef/knife/ionoscloud_natgateway_lan_add.rb +74 -0
  103. data/lib/chef/knife/ionoscloud_natgateway_lan_remove.rb +52 -0
  104. data/lib/chef/knife/ionoscloud_natgateway_list.rb +51 -0
  105. data/lib/chef/knife/ionoscloud_natgateway_rule_add.rb +107 -0
  106. data/lib/chef/knife/ionoscloud_natgateway_rule_list.rb +65 -0
  107. data/lib/chef/knife/ionoscloud_natgateway_rule_remove.rb +55 -0
  108. data/lib/chef/knife/ionoscloud_natgateway_rule_update.rb +116 -0
  109. data/lib/chef/knife/ionoscloud_natgateway_update.rb +84 -0
  110. data/lib/chef/knife/ionoscloud_networkloadbalancer_create.rb +89 -0
  111. data/lib/chef/knife/ionoscloud_networkloadbalancer_delete.rb +62 -0
  112. data/lib/chef/knife/ionoscloud_networkloadbalancer_get.rb +42 -0
  113. data/lib/chef/knife/ionoscloud_networkloadbalancer_list.rb +57 -0
  114. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_add.rb +141 -0
  115. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_list.rb +65 -0
  116. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_remove.rb +68 -0
  117. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_add.rb +124 -0
  118. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_list.rb +70 -0
  119. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove.rb +88 -0
  120. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_update.rb +148 -0
  121. data/lib/chef/knife/ionoscloud_networkloadbalancer_update.rb +98 -0
  122. data/lib/chef/knife/ionoscloud_nic_create.rb +17 -22
  123. data/lib/chef/knife/ionoscloud_nic_delete.rb +3 -7
  124. data/lib/chef/knife/ionoscloud_nic_get.rb +49 -0
  125. data/lib/chef/knife/ionoscloud_nic_list.rb +9 -5
  126. data/lib/chef/knife/ionoscloud_nic_update.rb +96 -0
  127. data/lib/chef/knife/ionoscloud_node_get.rb +49 -0
  128. data/lib/chef/knife/ionoscloud_node_list.rb +0 -1
  129. data/lib/chef/knife/ionoscloud_nodepool_create.rb +35 -48
  130. data/lib/chef/knife/ionoscloud_nodepool_delete.rb +1 -7
  131. data/lib/chef/knife/ionoscloud_nodepool_get.rb +43 -0
  132. data/lib/chef/knife/ionoscloud_nodepool_lan_add.rb +104 -0
  133. data/lib/chef/knife/ionoscloud_nodepool_lan_remove.rb +72 -0
  134. data/lib/chef/knife/ionoscloud_nodepool_list.rb +3 -1
  135. data/lib/chef/knife/ionoscloud_nodepool_update.rb +124 -0
  136. data/lib/chef/knife/ionoscloud_pcc_create.rb +12 -18
  137. data/lib/chef/knife/ionoscloud_pcc_delete.rb +2 -10
  138. data/lib/chef/knife/ionoscloud_pcc_get.rb +33 -0
  139. data/lib/chef/knife/ionoscloud_pcc_list.rb +1 -1
  140. data/lib/chef/knife/ionoscloud_pcc_update.rb +63 -0
  141. data/lib/chef/knife/ionoscloud_request_get.rb +40 -0
  142. data/lib/chef/knife/ionoscloud_request_list.rb +1 -1
  143. data/lib/chef/knife/ionoscloud_request_status.rb +1 -1
  144. data/lib/chef/knife/ionoscloud_s3key_create.rb +3 -7
  145. data/lib/chef/knife/ionoscloud_s3key_delete.rb +4 -7
  146. data/lib/chef/knife/ionoscloud_s3key_get.rb +38 -0
  147. data/lib/chef/knife/ionoscloud_s3key_list.rb +2 -2
  148. data/lib/chef/knife/ionoscloud_server_console.rb +43 -0
  149. data/lib/chef/knife/ionoscloud_server_create.rb +14 -26
  150. data/lib/chef/knife/ionoscloud_server_delete.rb +3 -9
  151. data/lib/chef/knife/ionoscloud_server_get.rb +43 -0
  152. data/lib/chef/knife/ionoscloud_server_list.rb +16 -5
  153. data/lib/chef/knife/ionoscloud_server_reboot.rb +1 -1
  154. data/lib/chef/knife/ionoscloud_server_resume.rb +44 -0
  155. data/lib/chef/knife/ionoscloud_server_start.rb +1 -1
  156. data/lib/chef/knife/ionoscloud_server_stop.rb +1 -1
  157. data/lib/chef/knife/ionoscloud_server_suspend.rb +45 -0
  158. data/lib/chef/knife/ionoscloud_server_token.rb +43 -0
  159. data/lib/chef/knife/ionoscloud_server_update.rb +97 -0
  160. data/lib/chef/knife/ionoscloud_server_upgrade.rb +45 -0
  161. data/lib/chef/knife/ionoscloud_share_create.rb +7 -11
  162. data/lib/chef/knife/ionoscloud_share_delete.rb +2 -3
  163. data/lib/chef/knife/ionoscloud_share_get.rb +38 -0
  164. data/lib/chef/knife/ionoscloud_share_update.rb +70 -0
  165. data/lib/chef/knife/ionoscloud_snapshot_create.rb +2 -10
  166. data/lib/chef/knife/ionoscloud_snapshot_delete.rb +2 -7
  167. data/lib/chef/knife/ionoscloud_snapshot_get.rb +32 -0
  168. data/lib/chef/knife/ionoscloud_snapshot_list.rb +1 -1
  169. data/lib/chef/knife/ionoscloud_snapshot_restore.rb +3 -14
  170. data/lib/chef/knife/ionoscloud_snapshot_update.rb +126 -0
  171. data/lib/chef/knife/ionoscloud_template_list.rb +47 -0
  172. data/lib/chef/knife/ionoscloud_user_create.rb +1 -8
  173. data/lib/chef/knife/ionoscloud_user_delete.rb +1 -6
  174. data/lib/chef/knife/ionoscloud_user_get.rb +32 -0
  175. data/lib/chef/knife/ionoscloud_user_ssourl.rb +1 -1
  176. data/lib/chef/knife/ionoscloud_user_update.rb +92 -0
  177. data/lib/chef/knife/ionoscloud_volume_attach.rb +1 -1
  178. data/lib/chef/knife/ionoscloud_volume_create.rb +18 -34
  179. data/lib/chef/knife/ionoscloud_volume_delete.rb +3 -9
  180. data/lib/chef/knife/ionoscloud_volume_detach.rb +1 -1
  181. data/lib/chef/knife/ionoscloud_volume_get.rb +36 -0
  182. data/lib/chef/knife/ionoscloud_volume_list.rb +2 -2
  183. data/lib/chef/knife/ionoscloud_volume_update.rb +106 -0
  184. data/lib/knife-ionoscloud/version.rb +1 -1
  185. data/spec/chef/knife/ionoscloud_backupunit_create_spec.rb +2 -2
  186. data/spec/chef/knife/ionoscloud_backupunit_delete_spec.rb +5 -5
  187. data/spec/chef/knife/ionoscloud_backupunit_get_spec.rb +65 -0
  188. data/spec/chef/knife/ionoscloud_backupunit_list_spec.rb +1 -1
  189. data/spec/chef/knife/ionoscloud_backupunit_ssourl_spec.rb +3 -3
  190. data/spec/chef/knife/ionoscloud_backupunit_update_spec.rb +78 -0
  191. data/spec/chef/knife/ionoscloud_base_spec.rb +4 -4
  192. data/spec/chef/knife/ionoscloud_composite_server_create_spec.rb +11 -8
  193. data/spec/chef/knife/ionoscloud_contract_list_spec.rb +32 -27
  194. data/spec/chef/knife/ionoscloud_cube_server_create_spec.rb +249 -0
  195. data/spec/chef/knife/ionoscloud_datacenter_create_spec.rb +6 -2
  196. data/spec/chef/knife/ionoscloud_datacenter_delete_spec.rb +8 -5
  197. data/spec/chef/knife/ionoscloud_datacenter_get_spec.rb +69 -0
  198. data/spec/chef/knife/ionoscloud_datacenter_list_spec.rb +5 -3
  199. data/spec/chef/knife/ionoscloud_datacenter_update_spec.rb +82 -0
  200. data/spec/chef/knife/ionoscloud_firewall_create_spec.rb +5 -3
  201. data/spec/chef/knife/ionoscloud_firewall_delete_spec.rb +6 -5
  202. data/spec/chef/knife/ionoscloud_firewall_get_spec.rb +77 -0
  203. data/spec/chef/knife/ionoscloud_firewall_list_spec.rb +5 -3
  204. data/spec/chef/knife/ionoscloud_firewall_update_spec.rb +117 -0
  205. data/spec/chef/knife/ionoscloud_flowlog_create_spec.rb +254 -0
  206. data/spec/chef/knife/ionoscloud_flowlog_delete_spec.rb +360 -0
  207. data/spec/chef/knife/ionoscloud_flowlog_get_spec.rb +171 -0
  208. data/spec/chef/knife/ionoscloud_flowlog_list_spec.rb +264 -0
  209. data/spec/chef/knife/ionoscloud_flowlog_update_spec.rb +244 -0
  210. data/spec/chef/knife/ionoscloud_group_create_spec.rb +9 -0
  211. data/spec/chef/knife/ionoscloud_group_delete_spec.rb +6 -0
  212. data/spec/chef/knife/ionoscloud_group_get_spec.rb +6 -0
  213. data/spec/chef/knife/ionoscloud_group_list_spec.rb +26 -8
  214. data/spec/chef/knife/ionoscloud_group_update_spec.rb +121 -0
  215. data/spec/chef/knife/ionoscloud_group_user_add_spec.rb +6 -0
  216. data/spec/chef/knife/ionoscloud_group_user_remove_spec.rb +6 -0
  217. data/spec/chef/knife/ionoscloud_image_list_spec.rb +2 -2
  218. data/spec/chef/knife/ionoscloud_ipblock_get_spec.rb +66 -0
  219. data/spec/chef/knife/ionoscloud_ipblock_update_spec.rb +79 -0
  220. data/spec/chef/knife/ionoscloud_ipfailover_add_spec.rb +4 -4
  221. data/spec/chef/knife/ionoscloud_ipfailover_remove_spec.rb +7 -7
  222. data/spec/chef/knife/ionoscloud_k8s_create_spec.rb +7 -0
  223. data/spec/chef/knife/ionoscloud_k8s_delete_spec.rb +16 -11
  224. data/spec/chef/knife/ionoscloud_k8s_get_spec.rb +72 -0
  225. data/spec/chef/knife/ionoscloud_k8s_update_spec.rb +114 -0
  226. data/spec/chef/knife/ionoscloud_kubeconfig_get_spec.rb +2 -2
  227. data/spec/chef/knife/ionoscloud_label_add_spec.rb +10 -10
  228. data/spec/chef/knife/ionoscloud_label_list_spec.rb +14 -14
  229. data/spec/chef/knife/ionoscloud_label_remove_spec.rb +20 -20
  230. data/spec/chef/knife/ionoscloud_lan_create_spec.rb +4 -3
  231. data/spec/chef/knife/ionoscloud_lan_delete_spec.rb +7 -5
  232. data/spec/chef/knife/ionoscloud_lan_get_spec.rb +68 -0
  233. data/spec/chef/knife/ionoscloud_lan_list_spec.rb +2 -2
  234. data/spec/chef/knife/ionoscloud_lan_update_spec.rb +87 -0
  235. data/spec/chef/knife/ionoscloud_loadbalancer_create_spec.rb +3 -3
  236. data/spec/chef/knife/ionoscloud_loadbalancer_delete_spec.rb +5 -5
  237. data/spec/chef/knife/ionoscloud_loadbalancer_get_spec.rb +2 -2
  238. data/spec/chef/knife/ionoscloud_loadbalancer_list_spec.rb +2 -2
  239. data/spec/chef/knife/ionoscloud_loadbalancer_nic_add_spec.rb +6 -6
  240. data/spec/chef/knife/ionoscloud_loadbalancer_nic_remove_spec.rb +6 -6
  241. data/spec/chef/knife/ionoscloud_loadbalancer_update_spec.rb +89 -0
  242. data/spec/chef/knife/ionoscloud_location_list_spec.rb +5 -3
  243. data/spec/chef/knife/ionoscloud_natgateway_create_spec.rb +92 -0
  244. data/spec/chef/knife/ionoscloud_natgateway_delete_spec.rb +118 -0
  245. data/spec/chef/knife/ionoscloud_natgateway_get_spec.rb +81 -0
  246. data/spec/chef/knife/ionoscloud_natgateway_lan_add_spec.rb +158 -0
  247. data/spec/chef/knife/ionoscloud_natgateway_lan_remove_spec.rb +209 -0
  248. data/spec/chef/knife/ionoscloud_natgateway_list_spec.rb +79 -0
  249. data/spec/chef/knife/ionoscloud_natgateway_rule_add_spec.rb +99 -0
  250. data/spec/chef/knife/ionoscloud_natgateway_rule_list_spec.rb +92 -0
  251. data/spec/chef/knife/ionoscloud_natgateway_rule_remove_spec.rb +78 -0
  252. data/spec/chef/knife/ionoscloud_natgateway_rule_update_spec.rb +121 -0
  253. data/spec/chef/knife/ionoscloud_natgateway_update_spec.rb +121 -0
  254. data/spec/chef/knife/ionoscloud_networkloadbalancer_create_spec.rb +93 -0
  255. data/spec/chef/knife/ionoscloud_networkloadbalancer_delete_spec.rb +120 -0
  256. data/spec/chef/knife/ionoscloud_networkloadbalancer_get_spec.rb +82 -0
  257. data/spec/chef/knife/ionoscloud_networkloadbalancer_list_spec.rb +88 -0
  258. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_add_spec.rb +105 -0
  259. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_list_spec.rb +89 -0
  260. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_remove_spec.rb +150 -0
  261. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_add_spec.rb +113 -0
  262. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_list_spec.rb +85 -0
  263. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove_spec.rb +281 -0
  264. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_update_spec.rb +163 -0
  265. data/spec/chef/knife/ionoscloud_networkloadbalancer_update_spec.rb +107 -0
  266. data/spec/chef/knife/ionoscloud_nic_create_spec.rb +9 -5
  267. data/spec/chef/knife/ionoscloud_nic_delete_spec.rb +8 -6
  268. data/spec/chef/knife/ionoscloud_nic_get_spec.rb +72 -0
  269. data/spec/chef/knife/ionoscloud_nic_list_spec.rb +12 -6
  270. data/spec/chef/knife/ionoscloud_nic_update_spec.rb +97 -0
  271. data/spec/chef/knife/ionoscloud_node_get_spec.rb +70 -0
  272. data/spec/chef/knife/ionoscloud_nodepool_create_spec.rb +10 -5
  273. data/spec/chef/knife/ionoscloud_nodepool_delete_spec.rb +14 -0
  274. data/spec/chef/knife/ionoscloud_nodepool_get_spec.rb +83 -0
  275. data/spec/chef/knife/ionoscloud_nodepool_lan_add_spec.rb +222 -0
  276. data/spec/chef/knife/ionoscloud_nodepool_lan_remove.rb +196 -0
  277. data/spec/chef/knife/ionoscloud_nodepool_list_spec.rb +3 -1
  278. data/spec/chef/knife/ionoscloud_nodepool_update_spec.rb +134 -0
  279. data/spec/chef/knife/ionoscloud_pcc_create_spec.rb +11 -8
  280. data/spec/chef/knife/ionoscloud_pcc_delete_spec.rb +7 -7
  281. data/spec/chef/knife/ionoscloud_pcc_get_spec.rb +71 -0
  282. data/spec/chef/knife/ionoscloud_pcc_list_spec.rb +2 -2
  283. data/spec/chef/knife/ionoscloud_pcc_update_spec.rb +83 -0
  284. data/spec/chef/knife/ionoscloud_request_get_spec.rb +69 -0
  285. data/spec/chef/knife/ionoscloud_request_list_spec.rb +16 -16
  286. data/spec/chef/knife/ionoscloud_request_status_spec.rb +3 -3
  287. data/spec/chef/knife/ionoscloud_s3key_create_spec.rb +2 -2
  288. data/spec/chef/knife/ionoscloud_s3key_delete_spec.rb +5 -5
  289. data/spec/chef/knife/ionoscloud_s3key_get_spec.rb +66 -0
  290. data/spec/chef/knife/ionoscloud_s3key_list_spec.rb +2 -2
  291. data/spec/chef/knife/ionoscloud_server_console_spec.rb +97 -0
  292. data/spec/chef/knife/ionoscloud_server_create_spec.rb +6 -3
  293. data/spec/chef/knife/ionoscloud_server_delete_spec.rb +8 -5
  294. data/spec/chef/knife/ionoscloud_server_get_spec.rb +74 -0
  295. data/spec/chef/knife/ionoscloud_server_list_spec.rb +63 -5
  296. data/spec/chef/knife/ionoscloud_server_reboot_spec.rb +3 -5
  297. data/spec/chef/knife/ionoscloud_server_resume_spec.rb +93 -0
  298. data/spec/chef/knife/ionoscloud_server_start_spec.rb +3 -5
  299. data/spec/chef/knife/ionoscloud_server_stop_spec.rb +3 -5
  300. data/spec/chef/knife/ionoscloud_server_suspend_spec.rb +93 -0
  301. data/spec/chef/knife/ionoscloud_server_token_spec.rb +97 -0
  302. data/spec/chef/knife/ionoscloud_server_update_spec.rb +105 -0
  303. data/spec/chef/knife/ionoscloud_server_upgrade_spec.rb +96 -0
  304. data/spec/chef/knife/ionoscloud_share_get_spec.rb +66 -0
  305. data/spec/chef/knife/ionoscloud_share_update_spec.rb +91 -0
  306. data/spec/chef/knife/ionoscloud_snapshot_create_spec.rb +15 -3
  307. data/spec/chef/knife/ionoscloud_snapshot_delete_spec.rb +17 -5
  308. data/spec/chef/knife/ionoscloud_snapshot_get_spec.rb +79 -0
  309. data/spec/chef/knife/ionoscloud_snapshot_list_spec.rb +2 -2
  310. data/spec/chef/knife/ionoscloud_snapshot_restore_spec.rb +12 -3
  311. data/spec/chef/knife/ionoscloud_snapshot_update_spec.rb +113 -0
  312. data/spec/chef/knife/ionoscloud_template_list_spec.rb +78 -0
  313. data/spec/chef/knife/ionoscloud_user_create_spec.rb +3 -1
  314. data/spec/chef/knife/ionoscloud_user_delete_spec.rb +4 -2
  315. data/spec/chef/knife/ionoscloud_user_get_spec.rb +70 -0
  316. data/spec/chef/knife/ionoscloud_user_ssourl_spec.rb +3 -3
  317. data/spec/chef/knife/ionoscloud_user_update_spec.rb +110 -0
  318. data/spec/chef/knife/ionoscloud_volume_attach_spec.rb +4 -4
  319. data/spec/chef/knife/ionoscloud_volume_create_spec.rb +21 -11
  320. data/spec/chef/knife/ionoscloud_volume_delete_spec.rb +15 -5
  321. data/spec/chef/knife/ionoscloud_volume_detach_spec.rb +5 -5
  322. data/spec/chef/knife/ionoscloud_volume_get_spec.rb +81 -0
  323. data/spec/chef/knife/ionoscloud_volume_list_spec.rb +4 -4
  324. data/spec/chef/knife/ionoscloud_volume_update_spec.rb +116 -0
  325. data/spec/spec_helper.rb +251 -39
  326. metadata +245 -6
@@ -0,0 +1,99 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_natgateway_rule_add'
3
+
4
+ Chef::Knife::IonoscloudNatgatewayRuleAdd.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudNatgatewayRuleAdd do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudNatgatewayRuleAdd.new }
9
+
10
+ allow(subject).to receive(:puts)
11
+ allow(subject).to receive(:print)
12
+ end
13
+
14
+ describe '#run' do
15
+ it 'should call NATGatewaysApi.datacenters_natgateways_rules_post when the ID is valid' do
16
+ natgateway = natgateway_mock
17
+ rule = natgateway_rule_mock
18
+ subject_config = {
19
+ ionoscloud_username: 'email',
20
+ ionoscloud_password: 'password',
21
+ datacenter_id: 'datacenter_id',
22
+ natgateway_id: natgateway.id,
23
+ name: rule.properties.name,
24
+ type: rule.properties.type,
25
+ protocol: rule.properties.protocol,
26
+ public_ip: rule.properties.public_ip,
27
+ source_subnet: rule.properties.source_subnet,
28
+ target_subnet: rule.properties.target_subnet,
29
+ target_port_range_start: rule.properties.target_port_range.start,
30
+ target_port_range_end: rule.properties.target_port_range._end,
31
+ yes: true,
32
+ }
33
+
34
+ subject_config.each { |key, value| subject.config[key] = value }
35
+
36
+ expect(subject).to receive(:puts).with("ID: #{natgateway.id}")
37
+ expect(subject).to receive(:puts).with("Name: #{natgateway.properties.name}")
38
+ expect(subject).to receive(:puts).with("IPS: #{natgateway.properties.public_ips}")
39
+ expect(subject).to receive(:puts).with("LANS: #{natgateway.properties.lans.map { |el| { id: el.id, gateway_ips: el.gateway_ips } }}")
40
+ expect(subject).to receive(:puts).with("Rules: #{(natgateway.entities.rules.items + [rule]).map do |el|
41
+ {
42
+ id: el.id,
43
+ name: el.properties.name,
44
+ type: el.properties.type,
45
+ protocol: el.properties.protocol,
46
+ public_ip: el.properties.public_ip,
47
+ source_subnet: el.properties.source_subnet,
48
+ target_subnet: el.properties.target_subnet,
49
+ target_port_range_start: el.properties.target_port_range ? el.properties.target_port_range.start : '',
50
+ target_port_range_end: el.properties.target_port_range ? el.properties.target_port_range._end : '',
51
+ }
52
+ end}")
53
+ expect(subject).to receive(:puts).with("Flowlogs: #{natgateway.entities.flowlogs.items.map { |flowlog| flowlog.id }}")
54
+
55
+ mock_wait_for(subject)
56
+ mock_call_api(
57
+ subject,
58
+ [
59
+ {
60
+ method: 'POST',
61
+ path: "/datacenters/#{subject_config[:datacenter_id]}/natgateways/#{natgateway.id}/rules",
62
+ operation: :'NATGatewaysApi.datacenters_natgateways_rules_post',
63
+ body: { properties: rule.properties.to_hash },
64
+ return_type: 'NatGatewayRule',
65
+ },
66
+ {
67
+ method: 'GET',
68
+ path: "/datacenters/#{subject_config[:datacenter_id]}/natgateways/#{natgateway.id}",
69
+ operation: :'NATGatewaysApi.datacenters_natgateways_find_by_nat_gateway_id',
70
+ return_type: 'NatGateway',
71
+ result: natgateway,
72
+ },
73
+ ],
74
+ )
75
+
76
+ natgateway.entities.rules.items << rule
77
+
78
+ expect { subject.run }.not_to raise_error(Exception)
79
+ end
80
+
81
+ it 'should not make any call if any required option is missing' do
82
+ required_options = subject.instance_variable_get(:@required_options)
83
+
84
+ arrays_without_one_element(required_options).each do |test_case|
85
+
86
+ test_case[:array].each { |value| subject.config[value] = 'test' }
87
+
88
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
89
+ expect(subject.api_client).not_to receive(:call_api)
90
+
91
+ expect { subject.run }.to raise_error(SystemExit) do |error|
92
+ expect(error.status).to eq(1)
93
+ end
94
+
95
+ required_options.each { |value| subject.config[value] = nil }
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_natgateway_rule_list'
3
+
4
+ Chef::Knife::IonoscloudNatgatewayRuleList.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudNatgatewayRuleList do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudNatgatewayRuleList.new }
9
+
10
+ allow(subject).to receive(:puts)
11
+ allow(subject).to receive(:print)
12
+ end
13
+
14
+ describe '#run' do
15
+ it 'should call NATGatewayApi.datacenters_natgateways_get' do
16
+ natgateway_rules = natgateway_rules_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ datacenter_id: 'datacenter_id',
21
+ natgateway_id: 'natgateway_id',
22
+ }
23
+
24
+ subject_config.each { |key, value| subject.config[key] = value }
25
+
26
+ natgateway_rule_list = [
27
+ subject.ui.color('ID', :bold),
28
+ subject.ui.color('Name', :bold),
29
+ subject.ui.color('Type', :bold),
30
+ subject.ui.color('Protocol', :bold),
31
+ subject.ui.color('Public IP', :bold),
32
+ subject.ui.color('Source Subnet', :bold),
33
+ subject.ui.color('Target Subnet', :bold),
34
+ subject.ui.color('Target Port Range Start', :bold),
35
+ subject.ui.color('Target Port Range End', :bold),
36
+ natgateway_rules.items[0].id,
37
+ natgateway_rules.items[0].properties.name,
38
+ natgateway_rules.items[0].properties.type,
39
+ natgateway_rules.items[0].properties.protocol,
40
+ natgateway_rules.items[0].properties.public_ip,
41
+ natgateway_rules.items[0].properties.source_subnet,
42
+ natgateway_rules.items[0].properties.target_subnet,
43
+ (natgateway_rules.items[0].properties.target_port_range ? natgateway_rules.items[0].properties.target_port_range.start : ''),
44
+ (natgateway_rules.items[0].properties.target_port_range ? natgateway_rules.items[0].properties.target_port_range._end : ''),
45
+ natgateway_rules.items[1].id,
46
+ natgateway_rules.items[1].properties.name,
47
+ natgateway_rules.items[1].properties.type,
48
+ natgateway_rules.items[1].properties.protocol,
49
+ natgateway_rules.items[1].properties.public_ip,
50
+ natgateway_rules.items[1].properties.source_subnet,
51
+ natgateway_rules.items[1].properties.target_subnet,
52
+ (natgateway_rules.items[1].properties.target_port_range ? natgateway_rules.items[1].properties.target_port_range.start : ''),
53
+ (natgateway_rules.items[1].properties.target_port_range ? natgateway_rules.items[1].properties.target_port_range._end : ''),
54
+ ]
55
+
56
+ expect(subject.ui).to receive(:list).with(natgateway_rule_list, :uneven_columns_across, 9)
57
+
58
+ mock_call_api(
59
+ subject,
60
+ [
61
+ {
62
+ method: 'GET',
63
+ path: "/datacenters/#{subject_config[:datacenter_id]}/natgateways/#{subject_config[:natgateway_id]}/rules",
64
+ operation: :'NATGatewaysApi.datacenters_natgateways_rules_get',
65
+ return_type: 'NatGatewayRules',
66
+ result: natgateway_rules,
67
+ },
68
+ ],
69
+ )
70
+
71
+ expect { subject.run }.not_to raise_error(Exception)
72
+ end
73
+
74
+ it 'should not make any call if any required option is missing' do
75
+ required_options = subject.instance_variable_get(:@required_options)
76
+
77
+ arrays_without_one_element(required_options).each do |test_case|
78
+
79
+ test_case[:array].each { |value| subject.config[value] = 'test' }
80
+
81
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
82
+ expect(subject.api_client).not_to receive(:call_api)
83
+
84
+ expect { subject.run }.to raise_error(SystemExit) do |error|
85
+ expect(error.status).to eq(1)
86
+ end
87
+
88
+ required_options.each { |value| subject.config[value] = nil }
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_natgateway_rule_remove'
3
+
4
+ Chef::Knife::IonoscloudNatgatewayRuleRemove.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudNatgatewayRuleRemove do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudNatgatewayRuleRemove.new }
9
+
10
+ allow(subject).to receive(:puts)
11
+ allow(subject).to receive(:print)
12
+ end
13
+
14
+ describe '#run' do
15
+ it 'should call NATGatewaysApi.datacenters_natgateways_rules_post when the ID is valid' do
16
+ rule = natgateway_rule_mock
17
+ natgateway = natgateway_mock(rules: [rule])
18
+ subject_config = {
19
+ ionoscloud_username: 'email',
20
+ ionoscloud_password: 'password',
21
+ datacenter_id: 'datacenter_id',
22
+ natgateway_id: natgateway.id,
23
+ yes: true,
24
+ }
25
+
26
+ subject_config.each { |key, value| subject.config[key] = value }
27
+ subject.name_args = [rule.id]
28
+
29
+ expect(subject).to receive(:puts).with("ID: #{natgateway.id}")
30
+ expect(subject).to receive(:puts).with("Name: #{natgateway.properties.name}")
31
+ expect(subject).to receive(:puts).with("IPS: #{natgateway.properties.public_ips}")
32
+ expect(subject).to receive(:puts).with("LANS: #{natgateway.properties.lans.map { |el| { id: el.id, gateway_ips: el.gateway_ips } }}")
33
+ expect(subject).to receive(:puts).with("Rules: #{[]}")
34
+ expect(subject).to receive(:puts).with("Flowlogs: #{natgateway.entities.flowlogs.items.map { |flowlog| flowlog.id }}")
35
+
36
+ mock_wait_for(subject)
37
+ mock_call_api(
38
+ subject,
39
+ [
40
+ {
41
+ method: 'DELETE',
42
+ path: "/datacenters/#{subject_config[:datacenter_id]}/natgateways/#{natgateway.id}/rules/#{rule.id}",
43
+ operation: :'NATGatewaysApi.datacenters_natgateways_rules_delete',
44
+ },
45
+ {
46
+ method: 'GET',
47
+ path: "/datacenters/#{subject_config[:datacenter_id]}/natgateways/#{natgateway.id}",
48
+ operation: :'NATGatewaysApi.datacenters_natgateways_find_by_nat_gateway_id',
49
+ return_type: 'NatGateway',
50
+ result: natgateway,
51
+ },
52
+ ],
53
+ )
54
+
55
+ natgateway.entities.rules.items = []
56
+
57
+ expect { subject.run }.not_to raise_error(Exception)
58
+ end
59
+
60
+ it 'should not make any call if any required option is missing' do
61
+ required_options = subject.instance_variable_get(:@required_options)
62
+
63
+ arrays_without_one_element(required_options).each do |test_case|
64
+
65
+ test_case[:array].each { |value| subject.config[value] = 'test' }
66
+
67
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
68
+ expect(subject.api_client).not_to receive(:call_api)
69
+
70
+ expect { subject.run }.to raise_error(SystemExit) do |error|
71
+ expect(error.status).to eq(1)
72
+ end
73
+
74
+ required_options.each { |value| subject.config[value] = nil }
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,121 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_natgateway_rule_update'
3
+
4
+ Chef::Knife::IonoscloudNatgatewayRuleUpdate.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudNatgatewayRuleUpdate do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudNatgatewayRuleUpdate.new }
9
+
10
+ allow(subject).to receive(:puts)
11
+ allow(subject).to receive(:print)
12
+ end
13
+
14
+ describe '#run' do
15
+ it 'should call NATGatewaysApi.datacenters_natgateways_rules_patch' do
16
+ natgateway = natgateway_mock
17
+ natgateway_rule = natgateway.entities.rules.items[0]
18
+
19
+ subject_config = {
20
+ ionoscloud_username: 'email',
21
+ ionoscloud_password: 'password',
22
+ datacenter_id: 'datacenter_id',
23
+ natgateway_id: natgateway.id,
24
+ natgateway_rule_id: natgateway_rule.id,
25
+ name: natgateway_rule.properties.name + '_edited',
26
+ type: 'SNAT',
27
+ protocol: 'UDP',
28
+ source_subnet: '10.2.1.1/24',
29
+ public_ip: '1.1.1.1',
30
+ target_subnet: '123.2.1.1/24',
31
+ target_port_range_start: natgateway_rule.properties.target_port_range.start + 10,
32
+ target_port_range_end: natgateway_rule.properties.target_port_range._end + 1,
33
+ yes: true,
34
+ }
35
+
36
+ subject_config.each { |key, value| subject.config[key] = value }
37
+
38
+ natgateway.entities.rules.items[0].properties.name = subject_config[:name]
39
+ natgateway.entities.rules.items[0].properties.type = subject_config[:type]
40
+ natgateway.entities.rules.items[0].properties.protocol = subject_config[:protocol]
41
+ natgateway.entities.rules.items[0].properties.source_subnet = subject_config[:source_subnet]
42
+ natgateway.entities.rules.items[0].properties.public_ip = subject_config[:public_ip]
43
+ natgateway.entities.rules.items[0].properties.target_subnet = subject_config[:target_subnet]
44
+ natgateway.entities.rules.items[0].properties.target_port_range.start = subject_config[:target_port_range_start]
45
+ natgateway.entities.rules.items[0].properties.target_port_range._end = subject_config[:target_port_range_end]
46
+
47
+ expect(subject).to receive(:puts).with("ID: #{natgateway.id}")
48
+ expect(subject).to receive(:puts).with("Name: #{natgateway.properties.name}")
49
+ expect(subject).to receive(:puts).with("IPS: #{natgateway.properties.public_ips}")
50
+ expect(subject).to receive(:puts).with("LANS: #{natgateway.properties.lans.map { |el| { id: el.id, gateway_ips: el.gateway_ips } }}")
51
+ expect(subject).to receive(:puts).with("Rules: #{natgateway.entities.rules.items.map do |el|
52
+ {
53
+ id: el.id,
54
+ name: el.properties.name,
55
+ type: el.properties.type,
56
+ protocol: el.properties.protocol,
57
+ public_ip: el.properties.public_ip,
58
+ source_subnet: el.properties.source_subnet,
59
+ target_subnet: el.properties.target_subnet,
60
+ target_port_range_start: el.properties.target_port_range ? el.properties.target_port_range.start : '',
61
+ target_port_range_end: el.properties.target_port_range ? el.properties.target_port_range._end : '',
62
+ }
63
+ end}")
64
+ expect(subject).to receive(:puts).with("Flowlogs: #{natgateway.entities.flowlogs.items.map { |flowlog| flowlog.id }}")
65
+
66
+ mock_wait_for(subject)
67
+ mock_call_api(
68
+ subject,
69
+ [
70
+ {
71
+ method: 'PATCH',
72
+ path: "/datacenters/#{subject_config[:datacenter_id]}/natgateways/#{subject_config[:natgateway_id]}/"\
73
+ "rules/#{subject_config[:natgateway_rule_id]}",
74
+ operation: :'NATGatewaysApi.datacenters_natgateways_rules_patch',
75
+ return_type: 'NatGatewayRule',
76
+ body: {
77
+ name: subject_config[:name],
78
+ type: subject_config[:type],
79
+ protocol: subject_config[:protocol],
80
+ publicIp: subject_config[:public_ip],
81
+ sourceSubnet: subject_config[:source_subnet],
82
+ targetSubnet: subject_config[:target_subnet],
83
+ targetPortRange: {
84
+ start: subject_config[:target_port_range_start],
85
+ end: subject_config[:target_port_range_end],
86
+ }
87
+ },
88
+ result: natgateway,
89
+ },
90
+ {
91
+ method: 'GET',
92
+ path: "/datacenters/#{subject_config[:datacenter_id]}/natgateways/#{subject_config[:natgateway_id]}",
93
+ operation: :'NATGatewaysApi.datacenters_natgateways_find_by_nat_gateway_id',
94
+ return_type: 'NatGateway',
95
+ result: natgateway,
96
+ },
97
+ ],
98
+ )
99
+
100
+ expect { subject.run }.not_to raise_error(Exception)
101
+ end
102
+
103
+ it 'should not make any call if any required option is missing' do
104
+ required_options = subject.instance_variable_get(:@required_options)
105
+
106
+ arrays_without_one_element(required_options).each do |test_case|
107
+
108
+ test_case[:array].each { |value| subject.config[value] = 'test' }
109
+
110
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
111
+ expect(subject.api_client).not_to receive(:call_api)
112
+
113
+ expect { subject.run }.to raise_error(SystemExit) do |error|
114
+ expect(error.status).to eq(1)
115
+ end
116
+
117
+ required_options.each { |value| subject.config[value] = nil }
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,121 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_natgateway_update'
3
+
4
+ Chef::Knife::IonoscloudNatgatewayUpdate.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudNatgatewayUpdate do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudNatgatewayUpdate.new }
9
+
10
+ allow(subject).to receive(:puts)
11
+ allow(subject).to receive(:print)
12
+ end
13
+
14
+ describe '#run' do
15
+ it 'should call NATGatewaysApi.datacenters_natgateways_patch' do
16
+ natgateway = natgateway_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ datacenter_id: 'datacenter_id',
21
+ natgateway_id: natgateway.id,
22
+ name: natgateway.properties.name + '_edited',
23
+ ips: (natgateway.properties.public_ips + ['3.3.3.3']).join(','),
24
+ lans: [
25
+ {
26
+ 'id' => 1,
27
+ 'gateway_ips' => [
28
+ '10.8.152.227/24',
29
+ '10.8.152.227/24',
30
+ ],
31
+ },
32
+ ],
33
+ yes: true,
34
+ }
35
+
36
+ subject_config.each { |key, value| subject.config[key] = value }
37
+
38
+ parsed_lans = subject_config[:lans].map do
39
+ |lan|
40
+ Ionoscloud::NatGatewayLanProperties.new(
41
+ id: lan['id'],
42
+ gateway_ips: lan['gateway_ips'],
43
+ )
44
+ end
45
+
46
+ expect(subject).to receive(:puts).with("ID: #{natgateway.id}")
47
+ expect(subject).to receive(:puts).with("Name: #{subject_config[:name]}")
48
+ expect(subject).to receive(:puts).with("IPS: #{subject_config[:ips].split(',')}")
49
+ expect(subject).to receive(:puts).with("LANS: #{subject_config[:lans].map do |lan|
50
+ {
51
+ id: lan['id'],
52
+ gateway_ips: lan['gateway_ips'],
53
+ }
54
+ end}")
55
+ expect(subject).to receive(:puts).with("Rules: #{natgateway.entities.rules.items.map do |el|
56
+ {
57
+ id: el.id,
58
+ name: el.properties.name,
59
+ type: el.properties.type,
60
+ protocol: el.properties.protocol,
61
+ public_ip: el.properties.public_ip,
62
+ source_subnet: el.properties.source_subnet,
63
+ target_subnet: el.properties.target_subnet,
64
+ target_port_range_start: el.properties.target_port_range ? el.properties.target_port_range.start : '',
65
+ target_port_range_end: el.properties.target_port_range ? el.properties.target_port_range._end : '',
66
+ }
67
+ end}")
68
+ expect(subject).to receive(:puts).with("Flowlogs: #{natgateway.entities.flowlogs.items.map { |flowlog| flowlog.id }}")
69
+
70
+ natgateway.properties.name = subject_config[:name]
71
+ natgateway.properties.public_ips = subject_config[:ips].split(',')
72
+ natgateway.properties.lans = parsed_lans
73
+
74
+ mock_wait_for(subject)
75
+ mock_call_api(
76
+ subject,
77
+ [
78
+ {
79
+ method: 'PATCH',
80
+ path: "/datacenters/#{subject_config[:datacenter_id]}/natgateways/#{subject_config[:natgateway_id]}",
81
+ operation: :'NATGatewaysApi.datacenters_natgateways_patch',
82
+ return_type: 'NatGateway',
83
+ body: {
84
+ name: subject_config[:name],
85
+ publicIps: subject_config[:ips].split(','),
86
+ lans: parsed_lans.map(&:to_hash),
87
+ },
88
+ result: natgateway,
89
+ },
90
+ {
91
+ method: 'GET',
92
+ path: "/datacenters/#{subject_config[:datacenter_id]}/natgateways/#{subject_config[:natgateway_id]}",
93
+ operation: :'NATGatewaysApi.datacenters_natgateways_find_by_nat_gateway_id',
94
+ return_type: 'NatGateway',
95
+ result: natgateway,
96
+ },
97
+ ],
98
+ )
99
+
100
+ expect { subject.run }.not_to raise_error(Exception)
101
+ end
102
+
103
+ it 'should not make any call if any required option is missing' do
104
+ required_options = subject.instance_variable_get(:@required_options)
105
+
106
+ arrays_without_one_element(required_options).each do |test_case|
107
+
108
+ test_case[:array].each { |value| subject.config[value] = 'test' }
109
+
110
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
111
+ expect(subject.api_client).not_to receive(:call_api)
112
+
113
+ expect { subject.run }.to raise_error(SystemExit) do |error|
114
+ expect(error.status).to eq(1)
115
+ end
116
+
117
+ required_options.each { |value| subject.config[value] = nil }
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,93 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_networkloadbalancer_create'
3
+
4
+ Chef::Knife::IonoscloudNetworkloadbalancerCreate.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudNetworkloadbalancerCreate do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudNetworkloadbalancerCreate.new }
9
+
10
+ allow(subject).to receive(:puts)
11
+ allow(subject).to receive(:print)
12
+ end
13
+
14
+ describe '#run' do
15
+ it 'should call NetworkLoadBalancersApi.datacenters_networkloadbalancers_post with the expected arguments and output based on what it receives' do
16
+ network_loadbalancer = network_loadbalancer_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ datacenter_id: 'datacenter_id',
21
+ name: network_loadbalancer.properties.name,
22
+ ips: network_loadbalancer.properties.ips.join(','),
23
+ listener_lan: network_loadbalancer.properties.listener_lan,
24
+ target_lan: network_loadbalancer.properties.target_lan,
25
+ lb_private_ips: network_loadbalancer.properties.lb_private_ips.join(','),
26
+ }.each do |key, value|
27
+ subject.config[key] = value
28
+ end
29
+
30
+ expect(subject).to receive(:puts).with("ID: #{network_loadbalancer.id}")
31
+ expect(subject).to receive(:puts).with("Name: #{network_loadbalancer.properties.name}")
32
+ expect(subject).to receive(:puts).with("Listener LAN: #{network_loadbalancer.properties.listener_lan}")
33
+ expect(subject).to receive(:puts).with("IPS: #{network_loadbalancer.properties.ips}")
34
+ expect(subject).to receive(:puts).with("Target LAN: #{network_loadbalancer.properties.target_lan}")
35
+ expect(subject).to receive(:puts).with("Private IPS: #{network_loadbalancer.properties.lb_private_ips}")
36
+ expect(subject).to receive(:puts).with("Forwarding Rules: #{network_loadbalancer.entities.forwardingrules.items.map do |rule|
37
+ {
38
+ id: rule.id,
39
+ name: rule.properties.name,
40
+ algorithm: rule.properties.algorithm,
41
+ protocol: rule.properties.protocol,
42
+ listener_ip: rule.properties.listener_ip,
43
+ listener_port: rule.properties.listener_port,
44
+ health_check: rule.properties.health_check.nil? ? nil : rule.properties.health_check.to_hash,
45
+ targets: (rule.properties.targets.nil? ? [] : rule.properties.targets.map { |target| target.to_hash }),
46
+ }
47
+ end}")
48
+ expect(subject).to receive(:puts).with("Flowlogs: #{network_loadbalancer.entities.flowlogs.items.map { |flowlog| flowlog.id }}")
49
+
50
+ mock_wait_for(subject)
51
+ mock_call_api(
52
+ subject,
53
+ [
54
+ {
55
+ method: 'POST',
56
+ path: "/datacenters/#{subject_config[:datacenter_id]}/networkloadbalancers",
57
+ operation: :'NetworkLoadBalancersApi.datacenters_networkloadbalancers_post',
58
+ return_type: 'NetworkLoadBalancer',
59
+ body: { properties: network_loadbalancer.properties.to_hash },
60
+ result: network_loadbalancer,
61
+ },
62
+ {
63
+ method: 'GET',
64
+ path: "/datacenters/#{subject_config[:datacenter_id]}/networkloadbalancers/#{network_loadbalancer.id}",
65
+ operation: :'NetworkLoadBalancersApi.datacenters_networkloadbalancers_find_by_network_load_balancer_id',
66
+ return_type: 'NetworkLoadBalancer',
67
+ result: network_loadbalancer,
68
+ },
69
+ ],
70
+ )
71
+
72
+ expect { subject.run }.not_to raise_error(Exception)
73
+ end
74
+
75
+ it 'should not make any call if any required option is missing' do
76
+ required_options = subject.instance_variable_get(:@required_options)
77
+
78
+ arrays_without_one_element(required_options).each do |test_case|
79
+
80
+ test_case[:array].each { |value| subject.config[value] = 'test' }
81
+
82
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
83
+ expect(subject.api_client).not_to receive(:call_api)
84
+
85
+ expect { subject.run }.to raise_error(SystemExit) do |error|
86
+ expect(error.status).to eq(1)
87
+ end
88
+
89
+ required_options.each { |value| subject.config[value] = nil }
90
+ end
91
+ end
92
+ end
93
+ end