knife-ionoscloud 6.0.0.beta.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 (193) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chef/knife/ionoscloud_backupunit_create.rb +10 -14
  3. data/lib/chef/knife/ionoscloud_backupunit_delete.rb +1 -4
  4. data/lib/chef/knife/ionoscloud_backupunit_get.rb +33 -0
  5. data/lib/chef/knife/ionoscloud_backupunit_update.rb +62 -0
  6. data/lib/chef/knife/ionoscloud_base.rb +308 -0
  7. data/lib/chef/knife/ionoscloud_cube_server_create.rb +3 -7
  8. data/lib/chef/knife/ionoscloud_datacenter_create.rb +10 -13
  9. data/lib/chef/knife/ionoscloud_datacenter_delete.rb +1 -6
  10. data/lib/chef/knife/ionoscloud_datacenter_get.rb +33 -0
  11. data/lib/chef/knife/ionoscloud_datacenter_update.rb +67 -0
  12. data/lib/chef/knife/ionoscloud_firewall_create.rb +7 -19
  13. data/lib/chef/knife/ionoscloud_firewall_delete.rb +2 -11
  14. data/lib/chef/knife/ionoscloud_firewall_get.rb +52 -0
  15. data/lib/chef/knife/ionoscloud_firewall_update.rb +133 -0
  16. data/lib/chef/knife/ionoscloud_flowlog_create.rb +4 -10
  17. data/lib/chef/knife/ionoscloud_flowlog_delete.rb +8 -12
  18. data/lib/chef/knife/ionoscloud_flowlog_get.rb +84 -0
  19. data/lib/chef/knife/ionoscloud_flowlog_list.rb +2 -2
  20. data/lib/chef/knife/ionoscloud_flowlog_update.rb +127 -0
  21. data/lib/chef/knife/ionoscloud_group_create.rb +1 -16
  22. data/lib/chef/knife/ionoscloud_group_delete.rb +1 -18
  23. data/lib/chef/knife/ionoscloud_group_get.rb +1 -19
  24. data/lib/chef/knife/ionoscloud_group_update.rb +131 -0
  25. data/lib/chef/knife/ionoscloud_group_user_add.rb +1 -18
  26. data/lib/chef/knife/ionoscloud_group_user_remove.rb +1 -18
  27. data/lib/chef/knife/ionoscloud_ipblock_create.rb +10 -13
  28. data/lib/chef/knife/ionoscloud_ipblock_delete.rb +1 -4
  29. data/lib/chef/knife/ionoscloud_ipblock_get.rb +33 -0
  30. data/lib/chef/knife/ionoscloud_ipblock_update.rb +57 -0
  31. data/lib/chef/knife/ionoscloud_k8s_create.rb +27 -35
  32. data/lib/chef/knife/ionoscloud_k8s_delete.rb +1 -9
  33. data/lib/chef/knife/ionoscloud_k8s_get.rb +33 -0
  34. data/lib/chef/knife/ionoscloud_k8s_update.rb +99 -0
  35. data/lib/chef/knife/ionoscloud_lan_create.rb +5 -13
  36. data/lib/chef/knife/ionoscloud_lan_delete.rb +2 -3
  37. data/lib/chef/knife/ionoscloud_lan_get.rb +38 -0
  38. data/lib/chef/knife/ionoscloud_lan_list.rb +1 -0
  39. data/lib/chef/knife/ionoscloud_lan_update.rb +76 -0
  40. data/lib/chef/knife/ionoscloud_loadbalancer_create.rb +3 -13
  41. data/lib/chef/knife/ionoscloud_loadbalancer_delete.rb +1 -8
  42. data/lib/chef/knife/ionoscloud_loadbalancer_get.rb +2 -12
  43. data/lib/chef/knife/ionoscloud_loadbalancer_nic_add.rb +2 -14
  44. data/lib/chef/knife/ionoscloud_loadbalancer_nic_remove.rb +2 -15
  45. data/lib/chef/knife/ionoscloud_loadbalancer_update.rb +73 -0
  46. data/lib/chef/knife/ionoscloud_natgateway_create.rb +4 -14
  47. data/lib/chef/knife/ionoscloud_natgateway_delete.rb +2 -18
  48. data/lib/chef/knife/ionoscloud_natgateway_get.rb +42 -0
  49. data/lib/chef/knife/ionoscloud_natgateway_lan_add.rb +1 -8
  50. data/lib/chef/knife/ionoscloud_natgateway_lan_remove.rb +1 -8
  51. data/lib/chef/knife/ionoscloud_natgateway_list.rb +1 -0
  52. data/lib/chef/knife/ionoscloud_natgateway_rule_add.rb +4 -22
  53. data/lib/chef/knife/ionoscloud_natgateway_rule_list.rb +1 -0
  54. data/lib/chef/knife/ionoscloud_natgateway_rule_remove.rb +3 -21
  55. data/lib/chef/knife/ionoscloud_natgateway_rule_update.rb +116 -0
  56. data/lib/chef/knife/ionoscloud_natgateway_update.rb +84 -0
  57. data/lib/chef/knife/ionoscloud_networkloadbalancer_create.rb +4 -11
  58. data/lib/chef/knife/ionoscloud_networkloadbalancer_delete.rb +2 -22
  59. data/lib/chef/knife/ionoscloud_networkloadbalancer_get.rb +42 -0
  60. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_add.rb +25 -35
  61. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_list.rb +1 -0
  62. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_remove.rb +19 -30
  63. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_add.rb +4 -22
  64. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_list.rb +1 -0
  65. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove.rb +4 -22
  66. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_update.rb +148 -0
  67. data/lib/chef/knife/ionoscloud_networkloadbalancer_update.rb +98 -0
  68. data/lib/chef/knife/ionoscloud_nic_create.rb +6 -16
  69. data/lib/chef/knife/ionoscloud_nic_delete.rb +2 -8
  70. data/lib/chef/knife/ionoscloud_nic_get.rb +49 -0
  71. data/lib/chef/knife/ionoscloud_nic_update.rb +96 -0
  72. data/lib/chef/knife/ionoscloud_node_get.rb +49 -0
  73. data/lib/chef/knife/ionoscloud_nodepool_create.rb +22 -51
  74. data/lib/chef/knife/ionoscloud_nodepool_delete.rb +1 -32
  75. data/lib/chef/knife/ionoscloud_nodepool_get.rb +43 -0
  76. data/lib/chef/knife/ionoscloud_nodepool_lan_add.rb +1 -26
  77. data/lib/chef/knife/ionoscloud_nodepool_lan_remove.rb +1 -26
  78. data/lib/chef/knife/ionoscloud_nodepool_update.rb +124 -0
  79. data/lib/chef/knife/ionoscloud_pcc_create.rb +9 -15
  80. data/lib/chef/knife/ionoscloud_pcc_delete.rb +1 -9
  81. data/lib/chef/knife/ionoscloud_pcc_get.rb +33 -0
  82. data/lib/chef/knife/ionoscloud_pcc_update.rb +63 -0
  83. data/lib/chef/knife/ionoscloud_request_get.rb +40 -0
  84. data/lib/chef/knife/ionoscloud_s3key_create.rb +1 -5
  85. data/lib/chef/knife/ionoscloud_s3key_delete.rb +1 -4
  86. data/lib/chef/knife/ionoscloud_s3key_get.rb +38 -0
  87. data/lib/chef/knife/ionoscloud_server_create.rb +12 -24
  88. data/lib/chef/knife/ionoscloud_server_delete.rb +2 -8
  89. data/lib/chef/knife/ionoscloud_server_get.rb +43 -0
  90. data/lib/chef/knife/ionoscloud_server_update.rb +97 -0
  91. data/lib/chef/knife/ionoscloud_share_create.rb +7 -11
  92. data/lib/chef/knife/ionoscloud_share_delete.rb +2 -3
  93. data/lib/chef/knife/ionoscloud_share_get.rb +38 -0
  94. data/lib/chef/knife/ionoscloud_share_update.rb +70 -0
  95. data/lib/chef/knife/ionoscloud_snapshot_create.rb +1 -9
  96. data/lib/chef/knife/ionoscloud_snapshot_delete.rb +1 -6
  97. data/lib/chef/knife/ionoscloud_snapshot_get.rb +32 -0
  98. data/lib/chef/knife/ionoscloud_snapshot_restore.rb +1 -12
  99. data/lib/chef/knife/ionoscloud_snapshot_update.rb +126 -0
  100. data/lib/chef/knife/ionoscloud_user_create.rb +1 -8
  101. data/lib/chef/knife/ionoscloud_user_delete.rb +1 -6
  102. data/lib/chef/knife/ionoscloud_user_get.rb +32 -0
  103. data/lib/chef/knife/ionoscloud_user_update.rb +92 -0
  104. data/lib/chef/knife/ionoscloud_volume_create.rb +1 -12
  105. data/lib/chef/knife/ionoscloud_volume_delete.rb +2 -8
  106. data/lib/chef/knife/ionoscloud_volume_get.rb +36 -0
  107. data/lib/chef/knife/ionoscloud_volume_update.rb +106 -0
  108. data/lib/knife-ionoscloud/version.rb +1 -1
  109. data/spec/chef/knife/ionoscloud_backupunit_get_spec.rb +65 -0
  110. data/spec/chef/knife/ionoscloud_backupunit_update_spec.rb +78 -0
  111. data/spec/chef/knife/ionoscloud_datacenter_create_spec.rb +3 -0
  112. data/spec/chef/knife/ionoscloud_datacenter_delete_spec.rb +3 -0
  113. data/spec/chef/knife/ionoscloud_datacenter_get_spec.rb +69 -0
  114. data/spec/chef/knife/ionoscloud_datacenter_update_spec.rb +82 -0
  115. data/spec/chef/knife/ionoscloud_firewall_create_spec.rb +1 -1
  116. data/spec/chef/knife/ionoscloud_firewall_delete_spec.rb +1 -1
  117. data/spec/chef/knife/ionoscloud_firewall_get_spec.rb +77 -0
  118. data/spec/chef/knife/ionoscloud_firewall_update_spec.rb +117 -0
  119. data/spec/chef/knife/ionoscloud_flowlog_create_spec.rb +3 -3
  120. data/spec/chef/knife/ionoscloud_flowlog_delete_spec.rb +10 -10
  121. data/spec/chef/knife/ionoscloud_flowlog_get_spec.rb +171 -0
  122. data/spec/chef/knife/ionoscloud_flowlog_list_spec.rb +3 -3
  123. data/spec/chef/knife/ionoscloud_flowlog_update_spec.rb +244 -0
  124. data/spec/chef/knife/ionoscloud_group_create_spec.rb +3 -0
  125. data/spec/chef/knife/ionoscloud_group_update_spec.rb +121 -0
  126. data/spec/chef/knife/ionoscloud_group_user_add_spec.rb +6 -0
  127. data/spec/chef/knife/ionoscloud_group_user_remove_spec.rb +6 -0
  128. data/spec/chef/knife/ionoscloud_ipblock_get_spec.rb +66 -0
  129. data/spec/chef/knife/ionoscloud_ipblock_update_spec.rb +79 -0
  130. data/spec/chef/knife/ionoscloud_ipfailover_add_spec.rb +1 -1
  131. data/spec/chef/knife/ionoscloud_ipfailover_remove_spec.rb +3 -3
  132. data/spec/chef/knife/ionoscloud_k8s_create_spec.rb +7 -0
  133. data/spec/chef/knife/ionoscloud_k8s_delete_spec.rb +16 -11
  134. data/spec/chef/knife/ionoscloud_k8s_get_spec.rb +72 -0
  135. data/spec/chef/knife/ionoscloud_k8s_update_spec.rb +114 -0
  136. data/spec/chef/knife/ionoscloud_lan_create_spec.rb +1 -0
  137. data/spec/chef/knife/ionoscloud_lan_delete_spec.rb +2 -0
  138. data/spec/chef/knife/ionoscloud_lan_get_spec.rb +68 -0
  139. data/spec/chef/knife/ionoscloud_lan_update_spec.rb +87 -0
  140. data/spec/chef/knife/ionoscloud_loadbalancer_update_spec.rb +89 -0
  141. data/spec/chef/knife/ionoscloud_natgateway_create_spec.rb +15 -0
  142. data/spec/chef/knife/ionoscloud_natgateway_get_spec.rb +81 -0
  143. data/spec/chef/knife/ionoscloud_natgateway_lan_add_spec.rb +15 -0
  144. data/spec/chef/knife/ionoscloud_natgateway_lan_remove_spec.rb +15 -0
  145. data/spec/chef/knife/ionoscloud_natgateway_rule_add_spec.rb +1 -0
  146. data/spec/chef/knife/ionoscloud_natgateway_rule_remove_spec.rb +1 -0
  147. data/spec/chef/knife/ionoscloud_natgateway_rule_update_spec.rb +121 -0
  148. data/spec/chef/knife/ionoscloud_natgateway_update_spec.rb +121 -0
  149. data/spec/chef/knife/ionoscloud_networkloadbalancer_create_spec.rb +13 -0
  150. data/spec/chef/knife/ionoscloud_networkloadbalancer_delete_spec.rb +3 -2
  151. data/spec/chef/knife/ionoscloud_networkloadbalancer_get_spec.rb +82 -0
  152. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_add_spec.rb +4 -3
  153. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_remove_spec.rb +70 -44
  154. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_add_spec.rb +26 -22
  155. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove_spec.rb +79 -61
  156. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_update_spec.rb +163 -0
  157. data/spec/chef/knife/ionoscloud_networkloadbalancer_update_spec.rb +107 -0
  158. data/spec/chef/knife/ionoscloud_nic_get_spec.rb +72 -0
  159. data/spec/chef/knife/ionoscloud_nic_update_spec.rb +97 -0
  160. data/spec/chef/knife/ionoscloud_node_get_spec.rb +70 -0
  161. data/spec/chef/knife/ionoscloud_nodepool_create_spec.rb +8 -17
  162. data/spec/chef/knife/ionoscloud_nodepool_delete_spec.rb +14 -0
  163. data/spec/chef/knife/ionoscloud_nodepool_get_spec.rb +83 -0
  164. data/spec/chef/knife/ionoscloud_nodepool_lan_add_spec.rb +29 -33
  165. data/spec/chef/knife/ionoscloud_nodepool_lan_remove.rb +14 -17
  166. data/spec/chef/knife/ionoscloud_nodepool_update_spec.rb +134 -0
  167. data/spec/chef/knife/ionoscloud_pcc_create_spec.rb +5 -2
  168. data/spec/chef/knife/ionoscloud_pcc_delete_spec.rb +2 -2
  169. data/spec/chef/knife/ionoscloud_pcc_get_spec.rb +71 -0
  170. data/spec/chef/knife/ionoscloud_pcc_update_spec.rb +83 -0
  171. data/spec/chef/knife/ionoscloud_request_get_spec.rb +69 -0
  172. data/spec/chef/knife/ionoscloud_s3key_get_spec.rb +66 -0
  173. data/spec/chef/knife/ionoscloud_server_create_spec.rb +3 -0
  174. data/spec/chef/knife/ionoscloud_server_delete_spec.rb +3 -0
  175. data/spec/chef/knife/ionoscloud_server_get_spec.rb +74 -0
  176. data/spec/chef/knife/ionoscloud_server_update_spec.rb +105 -0
  177. data/spec/chef/knife/ionoscloud_share_get_spec.rb +66 -0
  178. data/spec/chef/knife/ionoscloud_share_update_spec.rb +91 -0
  179. data/spec/chef/knife/ionoscloud_snapshot_create_spec.rb +12 -0
  180. data/spec/chef/knife/ionoscloud_snapshot_delete_spec.rb +12 -0
  181. data/spec/chef/knife/ionoscloud_snapshot_get_spec.rb +79 -0
  182. data/spec/chef/knife/ionoscloud_snapshot_restore_spec.rb +9 -0
  183. data/spec/chef/knife/ionoscloud_snapshot_update_spec.rb +113 -0
  184. data/spec/chef/knife/ionoscloud_user_create_spec.rb +3 -1
  185. data/spec/chef/knife/ionoscloud_user_delete_spec.rb +4 -2
  186. data/spec/chef/knife/ionoscloud_user_get_spec.rb +70 -0
  187. data/spec/chef/knife/ionoscloud_user_update_spec.rb +110 -0
  188. data/spec/chef/knife/ionoscloud_volume_create_spec.rb +15 -5
  189. data/spec/chef/knife/ionoscloud_volume_delete_spec.rb +10 -0
  190. data/spec/chef/knife/ionoscloud_volume_get_spec.rb +81 -0
  191. data/spec/chef/knife/ionoscloud_volume_update_spec.rb +116 -0
  192. data/spec/spec_helper.rb +41 -23
  193. metadata +125 -2
@@ -0,0 +1,116 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNatgatewayRuleUpdate < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud natgateway rule update (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: '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
+ option :natgateway_rule_id,
21
+ short: '-R RULE_ID',
22
+ long: '--rule-id RULE_ID',
23
+ description: 'ID of the NAT Gateway Rule'
24
+
25
+ option :name,
26
+ short: '-n NAME',
27
+ long: '--name NAME',
28
+ description: 'Name of the NAT gateway rule'
29
+
30
+ option :type,
31
+ short: '-t TYPE',
32
+ long: '--type TYPE',
33
+ description: 'Type of the NAT gateway rule'
34
+
35
+ option :protocol,
36
+ short: '-p PROTOCOL',
37
+ long: '--protocol PROTOCOL',
38
+ description: "Protocol of the NAT gateway rule. Defaults to ALL. If protocol is "\
39
+ "'ICMP' then target_port_range start and end cannot be set."
40
+
41
+ option :source_subnet,
42
+ long: '--source SOURCE_SUBNET',
43
+ description: 'Source subnet of the NAT gateway rule. For SNAT rules it specifies '\
44
+ 'which packets this translation rule applies to based on the packets source IP address.'
45
+
46
+ option :public_ip,
47
+ short: '-i PUBLIC_IP',
48
+ long: '--ip PUBLIC_IP',
49
+ description: 'Public IP address of the NAT gateway rule. Specifies the address used for masking outgoing '\
50
+ 'packets source address field. Should be one of the customer reserved IP address already configured on the NAT gateway resource'
51
+
52
+ option :target_subnet,
53
+ long: '--target TARGET_SUBNET',
54
+ description: 'Target or destination subnet of the NAT gateway rule. For SNAT rules it specifies which packets '\
55
+ 'this translation rule applies to based on the packets destination IP address. If none is provided, rule will match any address'
56
+
57
+ option :target_port_range_start,
58
+ long: '--port-start PORT_RANGE_START',
59
+ description: 'Target port range start associated with the NAT gateway rule'
60
+
61
+ option :target_port_range_end,
62
+ long: '--port-end PORT_RANGE_START',
63
+ description: 'Target port range end associated with the NAT gateway rule'
64
+
65
+ attr_reader :description, :required_options
66
+
67
+ def initialize(args = [])
68
+ super(args)
69
+ @description =
70
+ 'Updates information about a Ionoscloud NAT Gateway.'
71
+ @required_options = [:datacenter_id, :natgateway_id, :ionoscloud_username, :ionoscloud_password]
72
+ @updatable_fields = [
73
+ :name, :type, :protocol, :source_subnet, :public_ip, :target_subnet,
74
+ :target_port_range_start, :target_port_range_end,
75
+ ]
76
+ end
77
+
78
+ def run
79
+ $stdout.sync = true
80
+ handle_extra_config
81
+ validate_required_params(@required_options, config)
82
+
83
+ natgateways_api = Ionoscloud::NATGatewaysApi.new(api_client)
84
+
85
+ if @updatable_fields.map { |el| config[el] }.any?
86
+ print "#{ui.color('Updating NAT Gateway Rule...', :magenta)}"
87
+
88
+ _, _, headers = natgateways_api.datacenters_natgateways_rules_patch_with_http_info(
89
+ config[:datacenter_id],
90
+ config[:natgateway_id],
91
+ config[:natgateway_rule_id],
92
+ Ionoscloud::NatGatewayRuleProperties.new(
93
+ name: config[:name],
94
+ type: config[:type],
95
+ protocol: config[:protocol],
96
+ public_ip: config[:public_ip],
97
+ source_subnet: config[:source_subnet],
98
+ target_subnet: config[:target_subnet],
99
+ target_port_range: Ionoscloud::TargetPortRange.new(
100
+ start: config[:target_port_range_start],
101
+ _end: config[:target_port_range_end],
102
+ ),
103
+ ),
104
+ )
105
+
106
+ dot = ui.color('.', :magenta)
107
+ api_client.wait_for { print dot; is_done? get_request_id headers }
108
+ else
109
+ ui.warn("Nothing to update, please set one of the attributes #{@updatable_fields}.")
110
+ end
111
+
112
+ print_natgateway(natgateways_api.datacenters_natgateways_find_by_nat_gateway_id(config[:datacenter_id], config[:natgateway_id], depth: 2))
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,84 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNatgatewayUpdate < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud natgateway update (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: '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
+ option :name,
21
+ short: '-n NAME',
22
+ long: '--name NAME',
23
+ description: 'Name of the NAT gateway'
24
+
25
+ option :ips,
26
+ short: '-i IP[,IP,...]',
27
+ long: '--ips IP[,IP,...]',
28
+ description: 'Collection of public IP addresses of the NAT gateway. Should be customer reserved IP addresses in that location'
29
+
30
+ option :lans,
31
+ long: '--lans LAN[,LAN,...]',
32
+ description: 'Collection of LANs connected to the NAT gateway. IPs must contain valid subnet mask. If user will not provide any IP then system will generate an IP with /24 subnet.'
33
+
34
+ attr_reader :description, :required_options
35
+
36
+ def initialize(args = [])
37
+ super(args)
38
+ @description =
39
+ 'Updates information about a Ionoscloud NAT Gateway.'
40
+ @required_options = [:datacenter_id, :natgateway_id, :ionoscloud_username, :ionoscloud_password]
41
+ @updatable_fields = [:name, :ips, :lans]
42
+ end
43
+
44
+ def run
45
+ $stdout.sync = true
46
+ handle_extra_config
47
+ validate_required_params(@required_options, config)
48
+
49
+ natgateways_api = Ionoscloud::NATGatewaysApi.new(api_client)
50
+
51
+ config[:ips] = config[:ips].split(',') if config[:ips] && config[:ips].instance_of?(String)
52
+ config[:lans] = JSON[config[:lans]] if config[:lans] && config[:lans].instance_of?(String)
53
+ config[:lans] = config[:lans].map do
54
+ |lan|
55
+ Ionoscloud::NatGatewayLanProperties.new(
56
+ id: lan['id'],
57
+ gateway_ips: lan['gateway_ips'],
58
+ )
59
+ end if config[:lans]
60
+
61
+ if @updatable_fields.map { |el| config[el] }.any?
62
+ print "#{ui.color('Updating NAT Gateway...', :magenta)}"
63
+
64
+ _, _, headers = natgateways_api.datacenters_natgateways_patch_with_http_info(
65
+ config[:datacenter_id],
66
+ config[:natgateway_id],
67
+ Ionoscloud::NatGatewayProperties.new(
68
+ name: config[:name],
69
+ public_ips: config[:ips],
70
+ lans: config[:lans],
71
+ ),
72
+ )
73
+
74
+ dot = ui.color('.', :magenta)
75
+ api_client.wait_for { print dot; is_done? get_request_id headers }
76
+ else
77
+ ui.warn("Nothing to update, please set one of the attributes #{@updatable_fields}.")
78
+ end
79
+
80
+ print_natgateway(natgateways_api.datacenters_natgateways_find_by_nat_gateway_id(config[:datacenter_id], config[:natgateway_id], depth: 2))
81
+ end
82
+ end
83
+ end
84
+ end
@@ -78,18 +78,11 @@ class Chef
78
78
  dot = ui.color('.', :magenta)
79
79
  api_client.wait_for { print dot; is_done? get_request_id headers }
80
80
 
81
- network_load_balancer = network_load_balancers_api.datacenters_networkloadbalancers_find_by_network_load_balancer_id(
82
- config[:datacenter_id], network_load_balancer.id,
81
+ print_network_load_balancer(
82
+ network_load_balancers_api.datacenters_networkloadbalancers_find_by_network_load_balancer_id(
83
+ config[:datacenter_id], network_load_balancer.id, depth: 2,
84
+ ),
83
85
  )
84
-
85
- puts "\n"
86
- puts "#{ui.color('ID', :cyan)}: #{network_load_balancer.id}"
87
- puts "#{ui.color('Name', :cyan)}: #{network_load_balancer.properties.name}"
88
- puts "#{ui.color('Listener LAN', :cyan)}: #{network_load_balancer.properties.listener_lan}"
89
- puts "#{ui.color('IPS', :cyan)}: #{network_load_balancer.properties.ips}"
90
- puts "#{ui.color('Target LAN', :cyan)}: #{network_load_balancer.properties.target_lan}"
91
- puts "#{ui.color('Private IPS', :cyan)}: #{network_load_balancer.properties.lb_private_ips}"
92
- puts 'done'
93
86
  end
94
87
  end
95
88
  end
@@ -33,7 +33,7 @@ class Chef
33
33
  network_load_balancer = network_load_balancers_api.datacenters_networkloadbalancers_find_by_network_load_balancer_id(
34
34
  config[:datacenter_id],
35
35
  network_load_balancer_id,
36
- { depth: 1 },
36
+ depth: 2,
37
37
  )
38
38
  rescue Ionoscloud::ApiError => err
39
39
  raise err unless err.code == 404
@@ -41,27 +41,7 @@ class Chef
41
41
  next
42
42
  end
43
43
 
44
- msg_pair('ID', network_load_balancer.id)
45
- msg_pair('Name', network_load_balancer.properties.name)
46
- msg_pair('Listener LAN', network_load_balancer.properties.listener_lan)
47
- msg_pair('IPS', network_load_balancer.properties.ips)
48
- msg_pair('Target LAN', network_load_balancer.properties.target_lan)
49
- msg_pair('Private IPS', network_load_balancer.properties.lb_private_ips)
50
- msg_pair('Forwarding Rules', network_load_balancer.entities.forwardingrules.items.map do |rule|
51
- {
52
- id: rule.id,
53
- name: rule.properties.name,
54
- algorithm: rule.properties.algorithm,
55
- protocol: rule.properties.protocol,
56
- listener_ip: rule.properties.listener_ip,
57
- listener_port: rule.properties.listener_port,
58
- health_check: rule.properties.health_check,
59
- targets: rule.properties.targets,
60
- }
61
- end
62
- )
63
- # msg_pair('Flowlogs', network_load_balancer.entities.flowlogs.items.map { |flowlog| flowlog.id })
64
-
44
+ print_network_load_balancer(network_load_balancer)
65
45
  puts "\n"
66
46
 
67
47
  begin
@@ -0,0 +1,42 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNetworkloadbalancerGet < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud networkloadbalancer get (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'ID of the data center'
14
+
15
+ option :network_loadbalancer_id,
16
+ short: '-L NETWORK_LOADBALANCER_ID',
17
+ long: '--network-loadbalancer NETWORK_LOADBALANCER_ID',
18
+ description: 'ID of the Network Loadbalancer'
19
+
20
+ attr_reader :description, :required_options
21
+
22
+ def initialize(args = [])
23
+ super(args)
24
+ @description =
25
+ 'Retrieves the attributes of a given Network Load Balancer.'
26
+ @required_options = [:datacenter_id, :network_loadbalancer_id, :ionoscloud_username, :ionoscloud_password]
27
+ end
28
+
29
+ def run
30
+ $stdout.sync = true
31
+ handle_extra_config
32
+ validate_required_params(@required_options, config)
33
+
34
+ print_network_load_balancer(
35
+ Ionoscloud::NetworkLoadBalancersApi.new(api_client).datacenters_networkloadbalancers_find_by_network_load_balancer_id(
36
+ config[:datacenter_id], config[:network_loadbalancer_id], depth: 2,
37
+ ),
38
+ )
39
+ end
40
+ end
41
+ end
42
+ end
@@ -49,13 +49,6 @@ class Chef
49
49
  'the client is expected to acknowledge or send data. If unset the default of 50 seconds will be used.',
50
50
  default: 50
51
51
 
52
- option :check_timeout,
53
- long: '--check-timeout CLIENT_TIMEOUT',
54
- description: 'It specifies the time (in milliseconds) for a target VM in this pool to answer the check. '\
55
- 'If a target VM has CheckInterval set and CheckTimeout is set too, then the smaller value of the two is '\
56
- 'used after the TCP connection is established.',
57
- default: 2000
58
-
59
52
  option :connect_timeout,
60
53
  long: '--connect-timeout CONNECT_TIMEOUT',
61
54
  description: 'It specifies the maximum time (in milliseconds) to wait for a connection attempt to a '\
@@ -75,6 +68,10 @@ class Chef
75
68
  'If unset, the default value of 3 will be used. (valid range: [0, 65535])',
76
69
  default: 3
77
70
 
71
+ option :targets,
72
+ long: '--targets TARGETS',
73
+ description: 'Array of targets'
74
+
78
75
  attr_reader :description, :required_options
79
76
 
80
77
  def initialize(args = [])
@@ -91,9 +88,22 @@ class Chef
91
88
 
92
89
  network_loadbalancers_api = Ionoscloud::NetworkLoadBalancersApi.new(api_client)
93
90
 
94
- if config[:gateway_ips]
95
- config[:gateway_ips] = config[:gateway_ips].split(',')
96
- end
91
+ config[:gateway_ips] = config[:gateway_ips].split(',') if config[:gateway_ips] && config[:gateway_ips].instance_of?(String)
92
+ config[:targets] = JSON[config[:targets]] if config[:targets] && config[:targets].instance_of?(String)
93
+
94
+ config[:targets] = config[:targets].map do
95
+ |condition|
96
+ Ionoscloud::NetworkLoadBalancerForwardingRuleTarget.new(
97
+ ip: condition['ip'],
98
+ port: condition['port'],
99
+ weight: condition['weight'],
100
+ health_check: Ionoscloud::NetworkLoadBalancerForwardingRuleTargetHealthCheck.new(
101
+ check: condition['check'],
102
+ check_interval: condition['check_interval'],
103
+ maintenance: condition['maintenance'],
104
+ ),
105
+ )
106
+ end if config[:targets]
97
107
 
98
108
  network_loadbalancer_forwarding_rule = Ionoscloud::NetworkLoadBalancerForwardingRule.new(
99
109
  properties: Ionoscloud::NetworkLoadBalancerForwardingRuleProperties.new(
@@ -102,9 +112,9 @@ class Chef
102
112
  protocol: config[:protocol],
103
113
  listener_ip: config[:listener_ip],
104
114
  listener_port: config[:listener_port],
115
+ targets: config[:targets],
105
116
  health_check: Ionoscloud::NetworkLoadBalancerForwardingRuleHealthCheck.new(
106
117
  client_timeout: config[:client_timeout],
107
- check_timeout: config[:check_timeout],
108
118
  connect_timeout: config[:connect_timeout],
109
119
  target_timeout: config[:target_timeout],
110
120
  retries: config[:retries],
@@ -120,31 +130,11 @@ class Chef
120
130
  dot = ui.color('.', :magenta)
121
131
  api_client.wait_for { print dot; is_done? get_request_id headers }
122
132
 
123
- network_load_balancer = network_loadbalancers_api.datacenters_networkloadbalancers_find_by_network_load_balancer_id(
124
- config[:datacenter_id], config[:network_loadbalancer_id], depth: 2,
133
+ print_network_load_balancer(
134
+ network_loadbalancers_api.datacenters_networkloadbalancers_find_by_network_load_balancer_id(
135
+ config[:datacenter_id], config[:network_loadbalancer_id], depth: 2,
136
+ ),
125
137
  )
126
-
127
- puts "\n"
128
- puts "#{ui.color('ID', :cyan)}: #{network_load_balancer.id}"
129
- puts "#{ui.color('Name', :cyan)}: #{network_load_balancer.properties.name}"
130
- puts "#{ui.color('Listener LAN', :cyan)}: #{network_load_balancer.properties.listener_lan}"
131
- puts "#{ui.color('IPS', :cyan)}: #{network_load_balancer.properties.ips}"
132
- puts "#{ui.color('Target LAN', :cyan)}: #{network_load_balancer.properties.target_lan}"
133
- puts "#{ui.color('Private IPS', :cyan)}: #{network_load_balancer.properties.lb_private_ips}"
134
- puts "#{ui.color('Forwarding Rules', :cyan)}: #{network_load_balancer.entities.forwardingrules.items.map do |rule|
135
- {
136
- id: rule.id,
137
- name: rule.properties.name,
138
- algorithm: rule.properties.algorithm,
139
- protocol: rule.properties.protocol,
140
- listener_ip: rule.properties.listener_ip,
141
- listener_port: rule.properties.listener_port,
142
- health_check: rule.properties.health_check,
143
- targets: rule.properties.targets,
144
- }
145
- end}"
146
- puts "#{ui.color('Flowlogs', :cyan)}: #{network_load_balancer.entities.flowlogs.items.map { |flowlog| flowlog.id }}"
147
- puts 'done'
148
138
  end
149
139
  end
150
140
  end
@@ -32,6 +32,7 @@ class Chef
32
32
  validate_required_params(@required_options, config)
33
33
 
34
34
  $stdout.sync = true
35
+ handle_extra_config
35
36
  network_loadbalancer_rule_list = [
36
37
  ui.color('ID', :bold),
37
38
  ui.color('Name', :bold),
@@ -37,42 +37,31 @@ class Chef
37
37
 
38
38
  headers_to_wait = []
39
39
  @name_args.each do |rule_id|
40
- _, _, headers = network_loadbalancers_api.datacenters_networkloadbalancers_forwardingrules_delete_with_http_info(
41
- config[:datacenter_id], config[:network_loadbalancer_id], rule_id,
42
- )
43
- headers_to_wait << headers
40
+ begin
41
+ _, _, headers = network_loadbalancers_api.datacenters_networkloadbalancers_forwardingrules_delete_with_http_info(
42
+ config[:datacenter_id], config[:network_loadbalancer_id], rule_id,
43
+ )
44
+ headers_to_wait << headers
45
+
46
+ ui.warn(
47
+ "Removed Forwarding Rule #{rule_id} from the Network Load balancer "\
48
+ "#{config[:network_loadbalancer_id]}. Request ID: #{get_request_id headers}.",
49
+ )
50
+ rescue Ionoscloud::ApiError => err
51
+ raise err unless err.code == 404
52
+ ui.error("Forwarding rule ID #{rule_id} not found. Skipping.")
53
+ next
54
+ end
44
55
  end
45
56
 
46
- print "#{ui.color("Removing rules #{@name_args} from the NAT Gateway...", :magenta)}"
47
57
  dot = ui.color('.', :magenta)
48
-
49
58
  headers_to_wait.each { |headers| api_client.wait_for { print dot; is_done? get_request_id headers } }
50
59
 
51
- network_load_balancer = network_loadbalancers_api.datacenters_networkloadbalancers_find_by_network_load_balancer_id(
52
- config[:datacenter_id], config[:network_loadbalancer_id], depth: 2,
60
+ print_network_load_balancer(
61
+ network_loadbalancers_api.datacenters_networkloadbalancers_find_by_network_load_balancer_id(
62
+ config[:datacenter_id], config[:network_loadbalancer_id], depth: 2,
63
+ ),
53
64
  )
54
-
55
- puts "\n"
56
- puts "#{ui.color('ID', :cyan)}: #{network_load_balancer.id}"
57
- puts "#{ui.color('Name', :cyan)}: #{network_load_balancer.properties.name}"
58
- puts "#{ui.color('Listener LAN', :cyan)}: #{network_load_balancer.properties.listener_lan}"
59
- puts "#{ui.color('IPS', :cyan)}: #{network_load_balancer.properties.ips}"
60
- puts "#{ui.color('Target LAN', :cyan)}: #{network_load_balancer.properties.target_lan}"
61
- puts "#{ui.color('Private IPS', :cyan)}: #{network_load_balancer.properties.lb_private_ips}"
62
- puts "#{ui.color('Forwarding Rules', :cyan)}: #{network_load_balancer.entities.forwardingrules.items.map do |rule|
63
- {
64
- id: rule.id,
65
- name: rule.properties.name,
66
- algorithm: rule.properties.algorithm,
67
- protocol: rule.properties.protocol,
68
- listener_ip: rule.properties.listener_ip,
69
- listener_port: rule.properties.listener_port,
70
- health_check: rule.properties.health_check,
71
- targets: rule.properties.targets,
72
- }
73
- end}"
74
- puts "#{ui.color('Flowlogs', :cyan)}: #{network_load_balancer.entities.flowlogs.items.map { |flowlog| flowlog.id }}"
75
- puts 'done'
76
65
  end
77
66
  end
78
67
  end
@@ -113,29 +113,11 @@ class Chef
113
113
  dot = ui.color('.', :magenta)
114
114
  api_client.wait_for { print dot; is_done? get_request_id headers }
115
115
 
116
- network_load_balancer_rule = network_loadbalancers_api.datacenters_networkloadbalancers_forwardingrules_find_by_forwarding_rule_id(
117
- config[:datacenter_id], config[:network_loadbalancer_id], config[:forwarding_rule_id], depth: 2,
116
+ print_network_load_balancer(
117
+ network_loadbalancers_api.datacenters_networkloadbalancers_find_by_network_load_balancer_id(
118
+ config[:datacenter_id], config[:network_loadbalancer_id], depth: 2,
119
+ ),
118
120
  )
119
-
120
- puts "\n"
121
- puts "#{ui.color('ID', :cyan)}: #{network_load_balancer_rule.id}"
122
- puts "#{ui.color('Name', :cyan)}: #{network_load_balancer_rule.properties.name}"
123
- puts "#{ui.color('Algorithm', :cyan)}: #{network_load_balancer_rule.properties.algorithm}"
124
- puts "#{ui.color('Protocol', :cyan)}: #{network_load_balancer_rule.properties.protocol}"
125
- puts "#{ui.color('Listener IP', :cyan)}: #{network_load_balancer_rule.properties.listener_ip}"
126
- puts "#{ui.color('Listener Port', :cyan)}: #{network_load_balancer_rule.properties.listener_port}"
127
- puts "#{ui.color('Health Check', :cyan)}: #{network_load_balancer_rule.properties.health_check}"
128
- puts "#{ui.color('Targets', :cyan)}: #{network_load_balancer_rule.properties.targets.map do |target|
129
- {
130
- ip: target.ip,
131
- port: target.port,
132
- weight: target.weight,
133
- check: target.health_check.check,
134
- check_interval: target.health_check.check_interval,
135
- maintenance: target.health_check.maintenance,
136
- }
137
- end}"
138
- puts 'done'
139
121
  end
140
122
  end
141
123
  end
@@ -39,6 +39,7 @@ class Chef
39
39
  validate_required_params(@required_options, config)
40
40
 
41
41
  $stdout.sync = true
42
+ handle_extra_config
42
43
  target_list = [
43
44
  ui.color('IP', :bold),
44
45
  ui.color('Port', :bold),
@@ -77,29 +77,11 @@ class Chef
77
77
  api_client.wait_for { print dot; is_done? get_request_id headers }
78
78
  end
79
79
 
80
- network_load_balancer_rule = network_loadbalancers_api.datacenters_networkloadbalancers_forwardingrules_find_by_forwarding_rule_id(
81
- config[:datacenter_id], config[:network_loadbalancer_id], config[:forwarding_rule_id], depth: 2,
80
+ print_network_load_balancer(
81
+ network_loadbalancers_api.datacenters_networkloadbalancers_find_by_network_load_balancer_id(
82
+ config[:datacenter_id], config[:network_loadbalancer_id], depth: 2,
83
+ ),
82
84
  )
83
-
84
- puts "\n"
85
- puts "#{ui.color('ID', :cyan)}: #{network_load_balancer_rule.id}"
86
- puts "#{ui.color('Name', :cyan)}: #{network_load_balancer_rule.properties.name}"
87
- puts "#{ui.color('Algorithm', :cyan)}: #{network_load_balancer_rule.properties.algorithm}"
88
- puts "#{ui.color('Protocol', :cyan)}: #{network_load_balancer_rule.properties.protocol}"
89
- puts "#{ui.color('Listener IP', :cyan)}: #{network_load_balancer_rule.properties.listener_ip}"
90
- puts "#{ui.color('Listener Port', :cyan)}: #{network_load_balancer_rule.properties.listener_port}"
91
- puts "#{ui.color('Health Check', :cyan)}: #{network_load_balancer_rule.properties.health_check}"
92
- puts "#{ui.color('Targets', :cyan)}: #{network_load_balancer_rule.properties.targets.map do |target|
93
- {
94
- ip: target.ip,
95
- port: target.port,
96
- weight: target.weight,
97
- check: target.health_check.check,
98
- check_interval: target.health_check.check_interval,
99
- maintenance: target.health_check.maintenance,
100
- }
101
- end}"
102
- puts 'done'
103
85
  end
104
86
  end
105
87
  end