knife-ionoscloud 5.1.0 → 6.0.0.alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/knife-ionoscloud.gemspec +1 -1
  3. data/lib/chef/knife/ionoscloud_backupunit_create.rb +1 -1
  4. data/lib/chef/knife/ionoscloud_backupunit_delete.rb +1 -1
  5. data/lib/chef/knife/ionoscloud_backupunit_list.rb +1 -1
  6. data/lib/chef/knife/ionoscloud_backupunit_ssourl.rb +1 -1
  7. data/lib/chef/knife/ionoscloud_base.rb +1 -1
  8. data/lib/chef/knife/ionoscloud_composite_server_create.rb +25 -23
  9. data/lib/chef/knife/ionoscloud_contract_list.rb +32 -23
  10. data/lib/chef/knife/ionoscloud_cube_server_create.rb +215 -0
  11. data/lib/chef/knife/ionoscloud_datacenter_create.rb +1 -1
  12. data/lib/chef/knife/ionoscloud_datacenter_delete.rb +1 -1
  13. data/lib/chef/knife/ionoscloud_datacenter_list.rb +4 -2
  14. data/lib/chef/knife/ionoscloud_firewall_create.rb +11 -4
  15. data/lib/chef/knife/ionoscloud_firewall_delete.rb +4 -3
  16. data/lib/chef/knife/ionoscloud_firewall_list.rb +5 -3
  17. data/lib/chef/knife/ionoscloud_flowlog_create.rb +121 -0
  18. data/lib/chef/knife/ionoscloud_flowlog_delete.rb +106 -0
  19. data/lib/chef/knife/ionoscloud_flowlog_list.rb +100 -0
  20. data/lib/chef/knife/ionoscloud_group_create.rb +35 -14
  21. data/lib/chef/knife/ionoscloud_group_delete.rb +7 -0
  22. data/lib/chef/knife/ionoscloud_group_get.rb +6 -0
  23. data/lib/chef/knife/ionoscloud_group_list.rb +19 -7
  24. data/lib/chef/knife/ionoscloud_image_list.rb +1 -1
  25. data/lib/chef/knife/ionoscloud_ipfailover_add.rb +1 -1
  26. data/lib/chef/knife/ionoscloud_ipfailover_remove.rb +1 -1
  27. data/lib/chef/knife/ionoscloud_k8s_delete.rb +5 -2
  28. data/lib/chef/knife/ionoscloud_label_add.rb +1 -1
  29. data/lib/chef/knife/ionoscloud_label_list.rb +1 -1
  30. data/lib/chef/knife/ionoscloud_label_remove.rb +1 -1
  31. data/lib/chef/knife/ionoscloud_lan_create.rb +1 -1
  32. data/lib/chef/knife/ionoscloud_lan_delete.rb +1 -1
  33. data/lib/chef/knife/ionoscloud_lan_list.rb +1 -1
  34. data/lib/chef/knife/ionoscloud_loadbalancer_create.rb +1 -1
  35. data/lib/chef/knife/ionoscloud_loadbalancer_delete.rb +1 -1
  36. data/lib/chef/knife/ionoscloud_loadbalancer_get.rb +1 -1
  37. data/lib/chef/knife/ionoscloud_loadbalancer_list.rb +1 -1
  38. data/lib/chef/knife/ionoscloud_loadbalancer_nic_add.rb +1 -1
  39. data/lib/chef/knife/ionoscloud_loadbalancer_nic_remove.rb +1 -1
  40. data/lib/chef/knife/ionoscloud_location_list.rb +5 -3
  41. data/lib/chef/knife/ionoscloud_natgateway_create.rb +71 -0
  42. data/lib/chef/knife/ionoscloud_natgateway_delete.rb +69 -0
  43. data/lib/chef/knife/ionoscloud_natgateway_lan_add.rb +82 -0
  44. data/lib/chef/knife/ionoscloud_natgateway_lan_remove.rb +58 -0
  45. data/lib/chef/knife/ionoscloud_natgateway_list.rb +49 -0
  46. data/lib/chef/knife/ionoscloud_natgateway_rule_add.rb +124 -0
  47. data/lib/chef/knife/ionoscloud_natgateway_rule_list.rb +63 -0
  48. data/lib/chef/knife/ionoscloud_natgateway_rule_remove.rb +72 -0
  49. data/lib/chef/knife/ionoscloud_networkloadbalancer_create.rb +95 -0
  50. data/lib/chef/knife/ionoscloud_networkloadbalancer_delete.rb +81 -0
  51. data/lib/chef/knife/ionoscloud_networkloadbalancer_list.rb +56 -0
  52. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_add.rb +150 -0
  53. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_list.rb +63 -0
  54. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_remove.rb +78 -0
  55. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_add.rb +141 -0
  56. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_list.rb +68 -0
  57. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove.rb +105 -0
  58. data/lib/chef/knife/ionoscloud_nic_create.rb +14 -9
  59. data/lib/chef/knife/ionoscloud_nic_delete.rb +4 -2
  60. data/lib/chef/knife/ionoscloud_nic_list.rb +9 -5
  61. data/lib/chef/knife/ionoscloud_node_list.rb +0 -1
  62. data/lib/chef/knife/ionoscloud_nodepool_create.rb +42 -16
  63. data/lib/chef/knife/ionoscloud_nodepool_delete.rb +25 -0
  64. data/lib/chef/knife/ionoscloud_nodepool_lan_add.rb +130 -0
  65. data/lib/chef/knife/ionoscloud_nodepool_lan_remove.rb +96 -0
  66. data/lib/chef/knife/ionoscloud_nodepool_list.rb +3 -1
  67. data/lib/chef/knife/ionoscloud_pcc_create.rb +2 -2
  68. data/lib/chef/knife/ionoscloud_pcc_delete.rb +1 -1
  69. data/lib/chef/knife/ionoscloud_pcc_list.rb +1 -1
  70. data/lib/chef/knife/ionoscloud_request_list.rb +1 -1
  71. data/lib/chef/knife/ionoscloud_request_status.rb +1 -1
  72. data/lib/chef/knife/ionoscloud_s3key_create.rb +2 -2
  73. data/lib/chef/knife/ionoscloud_s3key_delete.rb +3 -3
  74. data/lib/chef/knife/ionoscloud_s3key_list.rb +2 -2
  75. data/lib/chef/knife/ionoscloud_server_console.rb +42 -0
  76. data/lib/chef/knife/ionoscloud_server_create.rb +8 -8
  77. data/lib/chef/knife/ionoscloud_server_delete.rb +1 -1
  78. data/lib/chef/knife/ionoscloud_server_list.rb +16 -5
  79. data/lib/chef/knife/ionoscloud_server_reboot.rb +1 -1
  80. data/lib/chef/knife/ionoscloud_server_resume.rb +43 -0
  81. data/lib/chef/knife/ionoscloud_server_start.rb +1 -1
  82. data/lib/chef/knife/ionoscloud_server_stop.rb +1 -1
  83. data/lib/chef/knife/ionoscloud_server_suspend.rb +44 -0
  84. data/lib/chef/knife/ionoscloud_server_token.rb +42 -0
  85. data/lib/chef/knife/ionoscloud_server_upgrade.rb +44 -0
  86. data/lib/chef/knife/ionoscloud_snapshot_create.rb +2 -2
  87. data/lib/chef/knife/ionoscloud_snapshot_delete.rb +1 -1
  88. data/lib/chef/knife/ionoscloud_snapshot_list.rb +1 -1
  89. data/lib/chef/knife/ionoscloud_snapshot_restore.rb +2 -2
  90. data/lib/chef/knife/ionoscloud_template_list.rb +46 -0
  91. data/lib/chef/knife/ionoscloud_user_ssourl.rb +1 -1
  92. data/lib/chef/knife/ionoscloud_volume_attach.rb +1 -1
  93. data/lib/chef/knife/ionoscloud_volume_create.rb +33 -35
  94. data/lib/chef/knife/ionoscloud_volume_delete.rb +1 -1
  95. data/lib/chef/knife/ionoscloud_volume_detach.rb +1 -1
  96. data/lib/chef/knife/ionoscloud_volume_list.rb +2 -2
  97. data/lib/knife-ionoscloud/version.rb +1 -1
  98. data/spec/chef/knife/ionoscloud_backupunit_create_spec.rb +2 -2
  99. data/spec/chef/knife/ionoscloud_backupunit_delete_spec.rb +5 -5
  100. data/spec/chef/knife/ionoscloud_backupunit_list_spec.rb +1 -1
  101. data/spec/chef/knife/ionoscloud_backupunit_ssourl_spec.rb +3 -3
  102. data/spec/chef/knife/ionoscloud_base_spec.rb +4 -4
  103. data/spec/chef/knife/ionoscloud_composite_server_create_spec.rb +11 -8
  104. data/spec/chef/knife/ionoscloud_contract_list_spec.rb +32 -27
  105. data/spec/chef/knife/ionoscloud_cube_server_create_spec.rb +249 -0
  106. data/spec/chef/knife/ionoscloud_datacenter_create_spec.rb +3 -2
  107. data/spec/chef/knife/ionoscloud_datacenter_delete_spec.rb +5 -5
  108. data/spec/chef/knife/ionoscloud_datacenter_list_spec.rb +5 -3
  109. data/spec/chef/knife/ionoscloud_firewall_create_spec.rb +5 -3
  110. data/spec/chef/knife/ionoscloud_firewall_delete_spec.rb +6 -5
  111. data/spec/chef/knife/ionoscloud_firewall_list_spec.rb +5 -3
  112. data/spec/chef/knife/ionoscloud_flowlog_create_spec.rb +254 -0
  113. data/spec/chef/knife/ionoscloud_flowlog_delete_spec.rb +360 -0
  114. data/spec/chef/knife/ionoscloud_flowlog_list_spec.rb +264 -0
  115. data/spec/chef/knife/ionoscloud_group_create_spec.rb +6 -0
  116. data/spec/chef/knife/ionoscloud_group_delete_spec.rb +6 -0
  117. data/spec/chef/knife/ionoscloud_group_get_spec.rb +6 -0
  118. data/spec/chef/knife/ionoscloud_group_list_spec.rb +26 -8
  119. data/spec/chef/knife/ionoscloud_image_list_spec.rb +2 -2
  120. data/spec/chef/knife/ionoscloud_ipfailover_add_spec.rb +3 -3
  121. data/spec/chef/knife/ionoscloud_ipfailover_remove_spec.rb +4 -4
  122. data/spec/chef/knife/ionoscloud_k8s_delete_spec.rb +5 -2
  123. data/spec/chef/knife/ionoscloud_kubeconfig_get_spec.rb +2 -2
  124. data/spec/chef/knife/ionoscloud_label_add_spec.rb +10 -10
  125. data/spec/chef/knife/ionoscloud_label_list_spec.rb +14 -14
  126. data/spec/chef/knife/ionoscloud_label_remove_spec.rb +20 -20
  127. data/spec/chef/knife/ionoscloud_lan_create_spec.rb +3 -3
  128. data/spec/chef/knife/ionoscloud_lan_delete_spec.rb +5 -5
  129. data/spec/chef/knife/ionoscloud_lan_list_spec.rb +2 -2
  130. data/spec/chef/knife/ionoscloud_loadbalancer_create_spec.rb +3 -3
  131. data/spec/chef/knife/ionoscloud_loadbalancer_delete_spec.rb +5 -5
  132. data/spec/chef/knife/ionoscloud_loadbalancer_get_spec.rb +2 -2
  133. data/spec/chef/knife/ionoscloud_loadbalancer_list_spec.rb +2 -2
  134. data/spec/chef/knife/ionoscloud_loadbalancer_nic_add_spec.rb +6 -6
  135. data/spec/chef/knife/ionoscloud_loadbalancer_nic_remove_spec.rb +6 -6
  136. data/spec/chef/knife/ionoscloud_location_list_spec.rb +5 -3
  137. data/spec/chef/knife/ionoscloud_natgateway_create_spec.rb +77 -0
  138. data/spec/chef/knife/ionoscloud_natgateway_delete_spec.rb +118 -0
  139. data/spec/chef/knife/ionoscloud_natgateway_lan_add_spec.rb +143 -0
  140. data/spec/chef/knife/ionoscloud_natgateway_lan_remove_spec.rb +194 -0
  141. data/spec/chef/knife/ionoscloud_natgateway_list_spec.rb +79 -0
  142. data/spec/chef/knife/ionoscloud_natgateway_rule_add_spec.rb +98 -0
  143. data/spec/chef/knife/ionoscloud_natgateway_rule_list_spec.rb +92 -0
  144. data/spec/chef/knife/ionoscloud_natgateway_rule_remove_spec.rb +77 -0
  145. data/spec/chef/knife/ionoscloud_networkloadbalancer_create_spec.rb +80 -0
  146. data/spec/chef/knife/ionoscloud_networkloadbalancer_delete_spec.rb +119 -0
  147. data/spec/chef/knife/ionoscloud_networkloadbalancer_list_spec.rb +88 -0
  148. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_add_spec.rb +104 -0
  149. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_list_spec.rb +89 -0
  150. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_remove_spec.rb +124 -0
  151. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_add_spec.rb +109 -0
  152. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_list_spec.rb +85 -0
  153. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove_spec.rb +263 -0
  154. data/spec/chef/knife/ionoscloud_nic_create_spec.rb +9 -5
  155. data/spec/chef/knife/ionoscloud_nic_delete_spec.rb +8 -6
  156. data/spec/chef/knife/ionoscloud_nic_list_spec.rb +12 -6
  157. data/spec/chef/knife/ionoscloud_nodepool_create_spec.rb +15 -1
  158. data/spec/chef/knife/ionoscloud_nodepool_lan_add_spec.rb +226 -0
  159. data/spec/chef/knife/ionoscloud_nodepool_lan_remove.rb +199 -0
  160. data/spec/chef/knife/ionoscloud_nodepool_list_spec.rb +3 -1
  161. data/spec/chef/knife/ionoscloud_pcc_create_spec.rb +6 -6
  162. data/spec/chef/knife/ionoscloud_pcc_delete_spec.rb +5 -5
  163. data/spec/chef/knife/ionoscloud_pcc_list_spec.rb +2 -2
  164. data/spec/chef/knife/ionoscloud_request_list_spec.rb +16 -16
  165. data/spec/chef/knife/ionoscloud_request_status_spec.rb +3 -3
  166. data/spec/chef/knife/ionoscloud_s3key_create_spec.rb +2 -2
  167. data/spec/chef/knife/ionoscloud_s3key_delete_spec.rb +5 -5
  168. data/spec/chef/knife/ionoscloud_s3key_list_spec.rb +2 -2
  169. data/spec/chef/knife/ionoscloud_server_console_spec.rb +97 -0
  170. data/spec/chef/knife/ionoscloud_server_create_spec.rb +3 -3
  171. data/spec/chef/knife/ionoscloud_server_delete_spec.rb +5 -5
  172. data/spec/chef/knife/ionoscloud_server_list_spec.rb +63 -5
  173. data/spec/chef/knife/ionoscloud_server_reboot_spec.rb +3 -5
  174. data/spec/chef/knife/ionoscloud_server_resume_spec.rb +93 -0
  175. data/spec/chef/knife/ionoscloud_server_start_spec.rb +3 -5
  176. data/spec/chef/knife/ionoscloud_server_stop_spec.rb +3 -5
  177. data/spec/chef/knife/ionoscloud_server_suspend_spec.rb +93 -0
  178. data/spec/chef/knife/ionoscloud_server_token_spec.rb +97 -0
  179. data/spec/chef/knife/ionoscloud_server_upgrade_spec.rb +96 -0
  180. data/spec/chef/knife/ionoscloud_snapshot_create_spec.rb +3 -3
  181. data/spec/chef/knife/ionoscloud_snapshot_delete_spec.rb +5 -5
  182. data/spec/chef/knife/ionoscloud_snapshot_list_spec.rb +2 -2
  183. data/spec/chef/knife/ionoscloud_snapshot_restore_spec.rb +3 -3
  184. data/spec/chef/knife/ionoscloud_template_list_spec.rb +78 -0
  185. data/spec/chef/knife/ionoscloud_user_ssourl_spec.rb +3 -3
  186. data/spec/chef/knife/ionoscloud_volume_attach_spec.rb +4 -4
  187. data/spec/chef/knife/ionoscloud_volume_create_spec.rb +6 -58
  188. data/spec/chef/knife/ionoscloud_volume_delete_spec.rb +5 -5
  189. data/spec/chef/knife/ionoscloud_volume_detach_spec.rb +5 -5
  190. data/spec/chef/knife/ionoscloud_volume_list_spec.rb +4 -4
  191. data/spec/spec_helper.rb +223 -29
  192. metadata +93 -6
@@ -0,0 +1,82 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNatgatewayLanAdd < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud natgateway lan add (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'Name of the data center'
14
+
15
+ option :natgateway_id,
16
+ short: '-G NATGATEWAY_ID',
17
+ long: '--natgateway-id NATGATEWAY_ID',
18
+ description: 'ID of the NAT Gateway'
19
+
20
+ option :lan_id,
21
+ short: '-L LAN_ID',
22
+ long: '--lan LAN_ID',
23
+ description: 'ID of the LAN'
24
+
25
+ option :gateway_ips,
26
+ short: '-i IP[,IP,...]',
27
+ long: '--ips IP[,IP,...]',
28
+ description: 'Collection of gateway IP addresses of the NAT gateway. '\
29
+ 'Will be auto-generated if not provided. Should ideally be an IP belonging to the same subnet as the LAN'
30
+
31
+ attr_reader :description, :required_options
32
+
33
+ def initialize(args = [])
34
+ super(args)
35
+ @description =
36
+ 'Adds a LAN to a Nat Gateway under a data center.'
37
+ @required_options = [:datacenter_id, :natgateway_id, :lan_id, :ionoscloud_username, :ionoscloud_password]
38
+ end
39
+
40
+ def run
41
+ $stdout.sync = true
42
+ validate_required_params(@required_options, config)
43
+
44
+ natgateways_api = Ionoscloud::NATGatewaysApi.new(api_client)
45
+
46
+ if config[:gateway_ips]
47
+ config[:gateway_ips] = config[:gateway_ips].split(',')
48
+ end
49
+
50
+ natgateway = natgateways_api.datacenters_natgateways_find_by_nat_gateway_id(config[:datacenter_id], config[:natgateway_id])
51
+
52
+ existing_lan = natgateway.properties.lans.find { |lan| lan.id == Integer(config[:lan_id]) }
53
+
54
+ if existing_lan
55
+ existing_lan.gateway_ips = config[:gateway_ips]
56
+ else
57
+ natgateway.properties.lans.append(
58
+ Ionoscloud::NatGatewayLanProperties.new(
59
+ id: Integer(config[:lan_id]),
60
+ gateway_ips: config[:gateway_ips],
61
+ ),
62
+ )
63
+ end
64
+
65
+ _, _, headers = natgateways_api.datacenters_natgateways_patch_with_http_info(config[:datacenter_id], config[:natgateway_id], natgateway.properties)
66
+
67
+ print "#{ui.color('Adding the LAN to the Nat Gateway...', :magenta)}"
68
+ dot = ui.color('.', :magenta)
69
+ api_client.wait_for { print dot; is_done? get_request_id headers }
70
+
71
+ natgateway = natgateways_api.datacenters_natgateways_find_by_nat_gateway_id(config[:datacenter_id], config[:natgateway_id])
72
+
73
+ puts "\n"
74
+ puts "#{ui.color('ID', :cyan)}: #{natgateway.id}"
75
+ puts "#{ui.color('Name', :cyan)}: #{natgateway.properties.name}"
76
+ puts "#{ui.color('IPS', :cyan)}: #{natgateway.properties.public_ips}"
77
+ puts "#{ui.color('LANS', :cyan)}: #{natgateway.properties.lans.map { |el| { id: el.id, gateway_ips: el.gateway_ips } }}"
78
+ puts 'done'
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,58 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNatgatewayLanRemove < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud natgateway lan remove LAN_ID [LAN_ID] (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'Name of the data center'
14
+
15
+ option :natgateway_id,
16
+ short: '-G NATGATEWAY_ID',
17
+ long: '--natgateway-id NATGATEWAY_ID',
18
+ description: 'ID of the NAT Gateway'
19
+
20
+ attr_reader :description, :required_options
21
+
22
+ def initialize(args = [])
23
+ super(args)
24
+ @description =
25
+ 'Removes the specified LANS from a Nat Gateway under a data center.'
26
+ @required_options = [:datacenter_id, :natgateway_id, :ionoscloud_username, :ionoscloud_password]
27
+ end
28
+
29
+ def run
30
+ $stdout.sync = true
31
+ validate_required_params(@required_options, config)
32
+
33
+ return unless @name_args.length > 0
34
+
35
+ natgateways_api = Ionoscloud::NATGatewaysApi.new(api_client)
36
+
37
+ natgateway = natgateways_api.datacenters_natgateways_find_by_nat_gateway_id(config[:datacenter_id], config[:natgateway_id])
38
+
39
+ natgateway.properties.lans = natgateway.properties.lans.reject { |lan| @name_args.map { |el| Integer(el) }.include? lan.id }
40
+
41
+ natgateway, _, headers = natgateways_api.datacenters_natgateways_patch_with_http_info(config[:datacenter_id], config[:natgateway_id], natgateway.properties)
42
+
43
+ print "#{ui.color("Removing LANS #{@name_args} from the NAT Gateway...", :magenta)}"
44
+ dot = ui.color('.', :magenta)
45
+ api_client.wait_for { print dot; is_done? get_request_id headers }
46
+
47
+ natgateway = natgateways_api.datacenters_natgateways_find_by_nat_gateway_id(config[:datacenter_id], natgateway.id)
48
+
49
+ puts "\n"
50
+ puts "#{ui.color('ID', :cyan)}: #{natgateway.id}"
51
+ puts "#{ui.color('Name', :cyan)}: #{natgateway.properties.name}"
52
+ puts "#{ui.color('IPS', :cyan)}: #{natgateway.properties.public_ips}"
53
+ puts "#{ui.color('LANS', :cyan)}: #{natgateway.properties.lans.map { |el| { id: el.id, gateway_ips: el.gateway_ips } }}"
54
+ puts 'done'
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,49 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNatgatewayList < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud natgateway list (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'The ID of the data center'
14
+
15
+ attr_reader :description, :required_options
16
+
17
+ def initialize(args = [])
18
+ super(args)
19
+ @description =
20
+ 'Lists all available NAT Gateways under a data center.'
21
+ @required_options = [:datacenter_id, :ionoscloud_username, :ionoscloud_password]
22
+ end
23
+
24
+ def run
25
+ $stdout.sync = true
26
+ validate_required_params(@required_options, config)
27
+
28
+ $stdout.sync = true
29
+ natgateway_list = [
30
+ ui.color('ID', :bold),
31
+ ui.color('Name', :bold),
32
+ ui.color('IPS', :bold),
33
+ ui.color('LANS', :bold),
34
+ ui.color('Rules Count', :bold),
35
+ ]
36
+ natgateways_api = Ionoscloud::NATGatewaysApi.new(api_client)
37
+
38
+ natgateways_api.datacenters_natgateways_get(config[:datacenter_id], { depth: 3 }).items.each do |natgateway|
39
+ natgateway_list << natgateway.id
40
+ natgateway_list << natgateway.properties.name
41
+ natgateway_list << natgateway.properties.public_ips
42
+ natgateway_list << natgateway.properties.lans.map { |el| { id: el.id, gateway_ips: el.gateway_ips } }
43
+ natgateway_list << natgateway.entities.rules.items.length
44
+ end
45
+ puts ui.list(natgateway_list, :uneven_columns_across, 5)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,124 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNatgatewayRuleAdd < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud natgateway rule add (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'Name of the data center'
14
+
15
+ option :natgateway_id,
16
+ short: '-G NATGATEWAY_ID',
17
+ long: '--natgateway-id NATGATEWAY_ID',
18
+ description: 'ID of the NAT Gateway'
19
+
20
+ option :name,
21
+ short: '-n NAME',
22
+ long: '--name NAME',
23
+ description: 'Name of the NAT gateway rule'
24
+
25
+ option :type,
26
+ short: '-t TYPE',
27
+ long: '--type TYPE',
28
+ description: 'Type of the NAT gateway rule',
29
+ default: 'SNAT'
30
+
31
+ option :protocol,
32
+ short: '-p PROTOCOL',
33
+ long: '--protocol PROTOCOL',
34
+ description: "Protocol of the NAT gateway rule. Defaults to ALL. If protocol is "\
35
+ "'ICMP' then target_port_range start and end cannot be set.",
36
+ default: 'ALL'
37
+
38
+ option :source_subnet,
39
+ long: '--source SOURCE_SUBNET',
40
+ description: 'Source subnet of the NAT gateway rule. For SNAT rules it specifies '\
41
+ 'which packets this translation rule applies to based on the packets source IP address.'
42
+
43
+ option :public_ip,
44
+ short: '-i PUBLIC_IP',
45
+ long: '--ip PUBLIC_IP',
46
+ description: 'Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing '\
47
+ 'packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource'
48
+
49
+ option :target_subnet,
50
+ long: '--target TARGET_SUBNET',
51
+ description: 'Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets '\
52
+ 'this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address'
53
+
54
+ option :target_port_range_start,
55
+ long: '--port-start PORT_RANGE_START',
56
+ description: 'Target port range start associated with the NAT gateway rule'
57
+
58
+ option :target_port_range_end,
59
+ long: '--port-end PORT_RANGE_START',
60
+ description: 'Target port range end associated with the NAT gateway rule'
61
+
62
+ attr_reader :description, :required_options
63
+
64
+ def initialize(args = [])
65
+ super(args)
66
+ @description =
67
+ 'Adds a LAN to a Nat Gateway under a data center.'
68
+ @required_options = [:datacenter_id, :natgateway_id, :name, :source_subnet, :public_ip, :ionoscloud_username, :ionoscloud_password]
69
+ end
70
+
71
+ def run
72
+ $stdout.sync = true
73
+ validate_required_params(@required_options, config)
74
+
75
+ natgateways_api = Ionoscloud::NATGatewaysApi.new(api_client)
76
+
77
+ natgateway_rule = Ionoscloud::NatGatewayRule.new(
78
+ properties: Ionoscloud::NatGatewayRuleProperties.new(
79
+ name: config[:name],
80
+ type: config[:type],
81
+ protocol: config[:protocol],
82
+ public_ip: config[:public_ip],
83
+ source_subnet: config[:source_subnet],
84
+ target_subnet: config[:target_subnet],
85
+ target_port_range: Ionoscloud::TargetPortRange.new(
86
+ start: config[:target_port_range_start],
87
+ _end: config[:target_port_range_end],
88
+ ),
89
+ ),
90
+ )
91
+
92
+ _, _, headers = natgateways_api.datacenters_natgateways_rules_post_with_http_info(
93
+ config[:datacenter_id], config[:natgateway_id], natgateway_rule,
94
+ )
95
+
96
+ print "#{ui.color('Adding the rule to the Nat Gateway...', :magenta)}"
97
+ dot = ui.color('.', :magenta)
98
+ api_client.wait_for { print dot; is_done? get_request_id headers }
99
+
100
+ natgateway = natgateways_api.datacenters_natgateways_find_by_nat_gateway_id(config[:datacenter_id], config[:natgateway_id], depth: 2)
101
+
102
+ puts "\n"
103
+ puts "#{ui.color('ID', :cyan)}: #{natgateway.id}"
104
+ puts "#{ui.color('Name', :cyan)}: #{natgateway.properties.name}"
105
+ puts "#{ui.color('IPS', :cyan)}: #{natgateway.properties.public_ips}"
106
+ puts "#{ui.color('LANS', :cyan)}: #{natgateway.properties.lans.map { |el| { id: el.id, gateway_ips: el.gateway_ips } }}"
107
+ puts "#{ui.color('Rules', :cyan)}: #{natgateway.entities.rules.items.map do |el|
108
+ {
109
+ id: el.id,
110
+ name: el.properties.name,
111
+ type: el.properties.type,
112
+ protocol: el.properties.protocol,
113
+ public_ip: el.properties.public_ip,
114
+ source_subnet: el.properties.source_subnet,
115
+ target_subnet: el.properties.target_subnet,
116
+ target_port_range_start: el.properties.target_port_range ? el.properties.target_port_range.start : '',
117
+ target_port_range_end: el.properties.target_port_range ? el.properties.target_port_range._end : '',
118
+ }
119
+ end}"
120
+ puts 'done'
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,63 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNatgatewayRuleList < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud natgateway rule list (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'The ID of the data center'
14
+
15
+ option :natgateway_id,
16
+ short: '-G NATGATEWAY_ID',
17
+ long: '--natgateway-id NATGATEWAY_ID',
18
+ description: 'ID of the NAT Gateway'
19
+
20
+ attr_reader :description, :required_options
21
+
22
+ def initialize(args = [])
23
+ super(args)
24
+ @description =
25
+ 'Lists all available rules in a NAT Gateways under a data center.'
26
+ @required_options = [:datacenter_id, :ionoscloud_username, :ionoscloud_password]
27
+ end
28
+
29
+ def run
30
+ $stdout.sync = true
31
+ validate_required_params(@required_options, config)
32
+
33
+ $stdout.sync = true
34
+ natgateway_rules_list = [
35
+ ui.color('ID', :bold),
36
+ ui.color('Name', :bold),
37
+ ui.color('Type', :bold),
38
+ ui.color('Protocol', :bold),
39
+ ui.color('Public IP', :bold),
40
+ ui.color('Source Subnet', :bold),
41
+ ui.color('Target Subnet', :bold),
42
+ ui.color('Target Port Range Start', :bold),
43
+ ui.color('Target Port Range End', :bold),
44
+ ]
45
+ natgateways_api = Ionoscloud::NATGatewaysApi.new(api_client)
46
+
47
+ natgateways_api.datacenters_natgateways_rules_get(config[:datacenter_id], config[:natgateway_id], { depth: 1 }).items.each do |natgateway_rule|
48
+ natgateway_rules_list << natgateway_rule.id
49
+ natgateway_rules_list << natgateway_rule.properties.name
50
+ natgateway_rules_list << natgateway_rule.properties.type
51
+ natgateway_rules_list << natgateway_rule.properties.protocol
52
+ natgateway_rules_list << natgateway_rule.properties.public_ip
53
+ natgateway_rules_list << natgateway_rule.properties.source_subnet
54
+ natgateway_rules_list << natgateway_rule.properties.target_subnet
55
+ natgateway_rules_list << (natgateway_rule.properties.target_port_range ? natgateway_rule.properties.target_port_range.start : '')
56
+ natgateway_rules_list << (natgateway_rule.properties.target_port_range ? natgateway_rule.properties.target_port_range._end : '')
57
+ end
58
+
59
+ puts ui.list(natgateway_rules_list, :uneven_columns_across, 9)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,72 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNatgatewayRuleRemove < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud natgateway rule remove RULE_ID [RULE_ID] (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'Name of the data center'
14
+
15
+ option :natgateway_id,
16
+ short: '-G NATGATEWAY_ID',
17
+ long: '--natgateway-id NATGATEWAY_ID',
18
+ description: 'ID of the NAT Gateway'
19
+
20
+ attr_reader :description, :required_options
21
+
22
+ def initialize(args = [])
23
+ super(args)
24
+ @description =
25
+ 'Removes the specified rules from a Nat Gateway under a data center.'
26
+ @required_options = [:datacenter_id, :natgateway_id, :ionoscloud_username, :ionoscloud_password]
27
+ end
28
+
29
+ def run
30
+ $stdout.sync = true
31
+ validate_required_params(@required_options, config)
32
+
33
+ return unless @name_args.length > 0
34
+
35
+ natgateways_api = Ionoscloud::NATGatewaysApi.new(api_client)
36
+
37
+ headers_to_wait = []
38
+ @name_args.each do |rule_id|
39
+ _, _, headers = natgateways_api.datacenters_natgateways_rules_delete_with_http_info(config[:datacenter_id], config[:natgateway_id], rule_id)
40
+ headers_to_wait << headers
41
+ end
42
+
43
+ print "#{ui.color("Removing rules #{@name_args} from the NAT Gateway...", :magenta)}"
44
+ dot = ui.color('.', :magenta)
45
+
46
+ headers_to_wait.each { |headers| api_client.wait_for { print dot; is_done? get_request_id headers } }
47
+
48
+ natgateway = natgateways_api.datacenters_natgateways_find_by_nat_gateway_id(config[:datacenter_id], config[:natgateway_id], depth: 2)
49
+
50
+ puts "\n"
51
+ puts "#{ui.color('ID', :cyan)}: #{natgateway.id}"
52
+ puts "#{ui.color('Name', :cyan)}: #{natgateway.properties.name}"
53
+ puts "#{ui.color('IPS', :cyan)}: #{natgateway.properties.public_ips}"
54
+ puts "#{ui.color('LANS', :cyan)}: #{natgateway.properties.lans.map { |el| { id: el.id, gateway_ips: el.gateway_ips } }}"
55
+ puts "#{ui.color('Rules', :cyan)}: #{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
+ puts 'done'
69
+ end
70
+ end
71
+ end
72
+ end