knife-ionoscloud 5.1.1 → 5.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/docs/README.md +5 -6
  3. data/docs/subcommands/backupunit_create.md +1 -1
  4. data/docs/subcommands/backupunit_get.md +35 -0
  5. data/docs/subcommands/backupunit_update.md +41 -0
  6. data/docs/subcommands/datacenter_get.md +35 -0
  7. data/docs/subcommands/datacenter_update.md +44 -0
  8. data/docs/subcommands/firewall_create.md +1 -1
  9. data/docs/subcommands/firewall_get.md +47 -0
  10. data/docs/subcommands/firewall_update.md +71 -0
  11. data/docs/subcommands/group_update.md +65 -0
  12. data/docs/subcommands/ipblock_get.md +35 -0
  13. data/docs/subcommands/ipblock_update.md +38 -0
  14. data/docs/subcommands/k8s_create.md +8 -5
  15. data/docs/subcommands/k8s_get.md +35 -0
  16. data/docs/subcommands/k8s_update.md +53 -0
  17. data/docs/subcommands/lan_get.md +39 -0
  18. data/docs/subcommands/lan_update.md +51 -0
  19. data/docs/subcommands/loadbalancer_create.md +1 -1
  20. data/docs/subcommands/loadbalancer_update.md +48 -0
  21. data/docs/subcommands/nic_create.md +3 -3
  22. data/docs/subcommands/nic_delete.md +1 -1
  23. data/docs/subcommands/nic_get.md +43 -0
  24. data/docs/subcommands/nic_update.md +58 -0
  25. data/docs/subcommands/node_get.md +43 -0
  26. data/docs/subcommands/nodepool_create.md +11 -5
  27. data/docs/subcommands/nodepool_get.md +39 -0
  28. data/docs/subcommands/nodepool_update.md +69 -0
  29. data/docs/subcommands/pcc_get.md +35 -0
  30. data/docs/subcommands/pcc_update.md +41 -0
  31. data/docs/subcommands/request_get.md +35 -0
  32. data/docs/subcommands/s3key_get.md +39 -0
  33. data/docs/subcommands/server_get.md +39 -0
  34. data/docs/subcommands/server_update.md +60 -0
  35. data/docs/subcommands/share_create.md +1 -1
  36. data/docs/subcommands/share_delete.md +2 -2
  37. data/docs/subcommands/share_get.md +39 -0
  38. data/docs/subcommands/share_update.md +45 -0
  39. data/docs/subcommands/snapshot_get.md +35 -0
  40. data/docs/subcommands/snapshot_update.md +77 -0
  41. data/docs/subcommands/user_create.md +9 -3
  42. data/docs/subcommands/user_get.md +35 -0
  43. data/docs/subcommands/user_update.md +56 -0
  44. data/docs/subcommands/volume_create.md +19 -1
  45. data/docs/subcommands/volume_get.md +39 -0
  46. data/docs/subcommands/volume_update.md +66 -0
  47. data/docs/summary.md +33 -0
  48. data/lib/chef/knife/ionoscloud_backupunit_create.rb +10 -15
  49. data/lib/chef/knife/ionoscloud_backupunit_delete.rb +1 -4
  50. data/lib/chef/knife/ionoscloud_backupunit_get.rb +33 -0
  51. data/lib/chef/knife/ionoscloud_backupunit_update.rb +62 -0
  52. data/lib/chef/knife/ionoscloud_base.rb +236 -6
  53. data/lib/chef/knife/ionoscloud_composite_server_create.rb +1 -13
  54. data/lib/chef/knife/ionoscloud_datacenter_create.rb +10 -13
  55. data/lib/chef/knife/ionoscloud_datacenter_delete.rb +1 -7
  56. data/lib/chef/knife/ionoscloud_datacenter_get.rb +33 -0
  57. data/lib/chef/knife/ionoscloud_datacenter_list.rb +3 -1
  58. data/lib/chef/knife/ionoscloud_datacenter_update.rb +67 -0
  59. data/lib/chef/knife/ionoscloud_firewall_create.rb +2 -13
  60. data/lib/chef/knife/ionoscloud_firewall_delete.rb +2 -10
  61. data/lib/chef/knife/ionoscloud_firewall_get.rb +50 -0
  62. data/lib/chef/knife/ionoscloud_firewall_update.rb +131 -0
  63. data/lib/chef/knife/ionoscloud_group_create.rb +17 -27
  64. data/lib/chef/knife/ionoscloud_group_delete.rb +1 -11
  65. data/lib/chef/knife/ionoscloud_group_get.rb +1 -11
  66. data/lib/chef/knife/ionoscloud_group_list.rb +13 -7
  67. data/lib/chef/knife/ionoscloud_group_update.rb +114 -0
  68. data/lib/chef/knife/ionoscloud_group_user_add.rb +1 -13
  69. data/lib/chef/knife/ionoscloud_group_user_remove.rb +1 -13
  70. data/lib/chef/knife/ionoscloud_ipblock_create.rb +10 -13
  71. data/lib/chef/knife/ionoscloud_ipblock_delete.rb +2 -4
  72. data/lib/chef/knife/ionoscloud_ipblock_get.rb +33 -0
  73. data/lib/chef/knife/ionoscloud_ipblock_list.rb +1 -1
  74. data/lib/chef/knife/ionoscloud_ipblock_update.rb +57 -0
  75. data/lib/chef/knife/ionoscloud_ipfailover_add.rb +7 -14
  76. data/lib/chef/knife/ionoscloud_ipfailover_remove.rb +1 -8
  77. data/lib/chef/knife/ionoscloud_k8s_create.rb +27 -30
  78. data/lib/chef/knife/ionoscloud_k8s_delete.rb +1 -9
  79. data/lib/chef/knife/ionoscloud_k8s_get.rb +33 -0
  80. data/lib/chef/knife/ionoscloud_k8s_update.rb +99 -0
  81. data/lib/chef/knife/ionoscloud_lan_create.rb +5 -13
  82. data/lib/chef/knife/ionoscloud_lan_delete.rb +2 -3
  83. data/lib/chef/knife/ionoscloud_lan_get.rb +38 -0
  84. data/lib/chef/knife/ionoscloud_lan_list.rb +3 -1
  85. data/lib/chef/knife/ionoscloud_lan_update.rb +87 -0
  86. data/lib/chef/knife/ionoscloud_loadbalancer_create.rb +3 -14
  87. data/lib/chef/knife/ionoscloud_loadbalancer_delete.rb +1 -9
  88. data/lib/chef/knife/ionoscloud_loadbalancer_get.rb +3 -13
  89. data/lib/chef/knife/ionoscloud_loadbalancer_nic_add.rb +3 -13
  90. data/lib/chef/knife/ionoscloud_loadbalancer_nic_remove.rb +3 -13
  91. data/lib/chef/knife/ionoscloud_loadbalancer_update.rb +73 -0
  92. data/lib/chef/knife/ionoscloud_nic_create.rb +14 -27
  93. data/lib/chef/knife/ionoscloud_nic_delete.rb +3 -8
  94. data/lib/chef/knife/ionoscloud_nic_get.rb +47 -0
  95. data/lib/chef/knife/ionoscloud_nic_update.rb +93 -0
  96. data/lib/chef/knife/ionoscloud_node_delete.rb +1 -6
  97. data/lib/chef/knife/ionoscloud_node_get.rb +47 -0
  98. data/lib/chef/knife/ionoscloud_nodepool_create.rb +45 -52
  99. data/lib/chef/knife/ionoscloud_nodepool_delete.rb +1 -7
  100. data/lib/chef/knife/ionoscloud_nodepool_get.rb +41 -0
  101. data/lib/chef/knife/ionoscloud_nodepool_update.rb +124 -0
  102. data/lib/chef/knife/ionoscloud_pcc_create.rb +10 -16
  103. data/lib/chef/knife/ionoscloud_pcc_delete.rb +1 -9
  104. data/lib/chef/knife/ionoscloud_pcc_get.rb +33 -0
  105. data/lib/chef/knife/ionoscloud_pcc_update.rb +63 -0
  106. data/lib/chef/knife/ionoscloud_request_get.rb +40 -0
  107. data/lib/chef/knife/ionoscloud_s3key_create.rb +1 -5
  108. data/lib/chef/knife/ionoscloud_s3key_delete.rb +1 -4
  109. data/lib/chef/knife/ionoscloud_s3key_get.rb +38 -0
  110. data/lib/chef/knife/ionoscloud_server_create.rb +12 -24
  111. data/lib/chef/knife/ionoscloud_server_delete.rb +1 -9
  112. data/lib/chef/knife/ionoscloud_server_get.rb +41 -0
  113. data/lib/chef/knife/ionoscloud_server_update.rb +97 -0
  114. data/lib/chef/knife/ionoscloud_share_create.rb +7 -12
  115. data/lib/chef/knife/ionoscloud_share_delete.rb +2 -4
  116. data/lib/chef/knife/ionoscloud_share_get.rb +38 -0
  117. data/lib/chef/knife/ionoscloud_share_update.rb +70 -0
  118. data/lib/chef/knife/ionoscloud_snapshot_create.rb +1 -9
  119. data/lib/chef/knife/ionoscloud_snapshot_delete.rb +1 -6
  120. data/lib/chef/knife/ionoscloud_snapshot_get.rb +32 -0
  121. data/lib/chef/knife/ionoscloud_snapshot_update.rb +126 -0
  122. data/lib/chef/knife/ionoscloud_user_create.rb +24 -20
  123. data/lib/chef/knife/ionoscloud_user_delete.rb +1 -7
  124. data/lib/chef/knife/ionoscloud_user_get.rb +32 -0
  125. data/lib/chef/knife/ionoscloud_user_update.rb +92 -0
  126. data/lib/chef/knife/ionoscloud_volume_create.rb +43 -23
  127. data/lib/chef/knife/ionoscloud_volume_delete.rb +1 -8
  128. data/lib/chef/knife/ionoscloud_volume_detach.rb +1 -8
  129. data/lib/chef/knife/ionoscloud_volume_get.rb +36 -0
  130. data/lib/chef/knife/ionoscloud_volume_update.rb +106 -0
  131. data/lib/knife-ionoscloud/version.rb +1 -1
  132. data/spec/chef/knife/ionoscloud_backupunit_get_spec.rb +65 -0
  133. data/spec/chef/knife/ionoscloud_backupunit_update_spec.rb +78 -0
  134. data/spec/chef/knife/ionoscloud_datacenter_create_spec.rb +10 -0
  135. data/spec/chef/knife/ionoscloud_datacenter_delete_spec.rb +3 -0
  136. data/spec/chef/knife/ionoscloud_datacenter_get_spec.rb +69 -0
  137. data/spec/chef/knife/ionoscloud_datacenter_list_spec.rb +3 -1
  138. data/spec/chef/knife/ionoscloud_datacenter_update_spec.rb +82 -0
  139. data/spec/chef/knife/ionoscloud_firewall_get_spec.rb +76 -0
  140. data/spec/chef/knife/ionoscloud_firewall_update_spec.rb +116 -0
  141. data/spec/chef/knife/ionoscloud_group_create_spec.rb +7 -0
  142. data/spec/chef/knife/ionoscloud_group_delete_spec.rb +3 -0
  143. data/spec/chef/knife/ionoscloud_group_get_spec.rb +3 -0
  144. data/spec/chef/knife/ionoscloud_group_list_spec.rb +17 -8
  145. data/spec/chef/knife/ionoscloud_group_update_spec.rb +109 -0
  146. data/spec/chef/knife/ionoscloud_group_user_add_spec.rb +3 -0
  147. data/spec/chef/knife/ionoscloud_group_user_remove_spec.rb +3 -0
  148. data/spec/chef/knife/ionoscloud_ipblock_delete_spec.rb +2 -0
  149. data/spec/chef/knife/ionoscloud_ipblock_get_spec.rb +66 -0
  150. data/spec/chef/knife/ionoscloud_ipblock_list_spec.rb +1 -1
  151. data/spec/chef/knife/ionoscloud_ipblock_update_spec.rb +79 -0
  152. data/spec/chef/knife/ionoscloud_ipfailover_add_spec.rb +2 -1
  153. data/spec/chef/knife/ionoscloud_ipfailover_remove_spec.rb +4 -3
  154. data/spec/chef/knife/ionoscloud_k8s_create_spec.rb +8 -0
  155. data/spec/chef/knife/ionoscloud_k8s_delete_spec.rb +7 -1
  156. data/spec/chef/knife/ionoscloud_k8s_get_spec.rb +73 -0
  157. data/spec/chef/knife/ionoscloud_k8s_update_spec.rb +115 -0
  158. data/spec/chef/knife/ionoscloud_lan_create_spec.rb +1 -0
  159. data/spec/chef/knife/ionoscloud_lan_delete_spec.rb +2 -0
  160. data/spec/chef/knife/ionoscloud_lan_get_spec.rb +68 -0
  161. data/spec/chef/knife/ionoscloud_lan_list_spec.rb +3 -1
  162. data/spec/chef/knife/ionoscloud_lan_update_spec.rb +91 -0
  163. data/spec/chef/knife/ionoscloud_loadbalancer_update_spec.rb +89 -0
  164. data/spec/chef/knife/ionoscloud_nic_get_spec.rb +70 -0
  165. data/spec/chef/knife/ionoscloud_nic_update_spec.rb +92 -0
  166. data/spec/chef/knife/ionoscloud_node_get_spec.rb +70 -0
  167. data/spec/chef/knife/ionoscloud_nodepool_create_spec.rb +12 -5
  168. data/spec/chef/knife/ionoscloud_nodepool_delete_spec.rb +27 -13
  169. data/spec/chef/knife/ionoscloud_nodepool_get_spec.rb +83 -0
  170. data/spec/chef/knife/ionoscloud_nodepool_update_spec.rb +130 -0
  171. data/spec/chef/knife/ionoscloud_pcc_create_spec.rb +5 -2
  172. data/spec/chef/knife/ionoscloud_pcc_delete_spec.rb +1 -1
  173. data/spec/chef/knife/ionoscloud_pcc_get_spec.rb +71 -0
  174. data/spec/chef/knife/ionoscloud_pcc_update_spec.rb +83 -0
  175. data/spec/chef/knife/ionoscloud_request_get_spec.rb +69 -0
  176. data/spec/chef/knife/ionoscloud_request_list_spec.rb +9 -8
  177. data/spec/chef/knife/ionoscloud_s3key_get_spec.rb +66 -0
  178. data/spec/chef/knife/ionoscloud_server_get_spec.rb +71 -0
  179. data/spec/chef/knife/ionoscloud_server_update_spec.rb +102 -0
  180. data/spec/chef/knife/ionoscloud_share_get_spec.rb +66 -0
  181. data/spec/chef/knife/ionoscloud_share_update_spec.rb +91 -0
  182. data/spec/chef/knife/ionoscloud_snapshot_create_spec.rb +13 -0
  183. data/spec/chef/knife/ionoscloud_snapshot_delete_spec.rb +12 -0
  184. data/spec/chef/knife/ionoscloud_snapshot_get_spec.rb +79 -0
  185. data/spec/chef/knife/ionoscloud_snapshot_update_spec.rb +113 -0
  186. data/spec/chef/knife/ionoscloud_user_create_spec.rb +3 -1
  187. data/spec/chef/knife/ionoscloud_user_delete_spec.rb +4 -2
  188. data/spec/chef/knife/ionoscloud_user_get_spec.rb +70 -0
  189. data/spec/chef/knife/ionoscloud_user_update_spec.rb +110 -0
  190. data/spec/chef/knife/ionoscloud_volume_create_spec.rb +9 -0
  191. data/spec/chef/knife/ionoscloud_volume_delete_spec.rb +9 -0
  192. data/spec/chef/knife/ionoscloud_volume_detach_spec.rb +9 -0
  193. data/spec/chef/knife/ionoscloud_volume_get_spec.rb +80 -0
  194. data/spec/chef/knife/ionoscloud_volume_update_spec.rb +115 -0
  195. data/spec/spec_helper.rb +90 -50
  196. metadata +134 -2
@@ -28,10 +28,7 @@ class Chef
28
28
  description: 'IPs assigned to the NIC'
29
29
 
30
30
  option :dhcp,
31
- short: '-d',
32
- long: '--dhcp',
33
- boolean: true | false,
34
- default: true,
31
+ long: '--dhcp DHCP',
35
32
  description: 'Set to false if you wish to disable DHCP'
36
33
 
37
34
  option :lan,
@@ -40,7 +37,7 @@ class Chef
40
37
  description: 'The LAN ID the NIC will reside on; if the LAN ID does not exist it will be created'
41
38
 
42
39
  option :nat,
43
- long: '--nat',
40
+ long: '--nat NAT',
44
41
  description: 'Set to enable NAT on the NIC'
45
42
 
46
43
  attr_reader :description, :required_options
@@ -62,40 +59,30 @@ class Chef
62
59
 
63
60
  config[:ips] = config[:ips].split(',') if config[:ips] && config[:ips].instance_of?(String)
64
61
 
65
- params = {
66
- name: config[:name],
67
- ips: config[:ips],
68
- dhcp: config[:dhcp],
69
- lan: config[:lan],
70
- nat: !config[:nat].nil?,
71
- }
72
-
73
62
  nic_api = Ionoscloud::NicApi.new(api_client)
74
63
 
75
64
  nic, _, headers = nic_api.datacenters_servers_nics_post_with_http_info(
76
65
  config[:datacenter_id],
77
66
  config[:server_id],
78
- { properties: params.compact },
67
+ Ionoscloud::Nic.new(
68
+ properties: Ionoscloud::NicProperties.new(
69
+ name: config[:name],
70
+ ips: config[:ips],
71
+ dhcp: (config.key?(:dhcp) ? config[:dhcp].to_s.downcase == 'true' : nil),
72
+ lan: config[:lan],
73
+ nat: (config.key?(:nat) ? config[:nat].to_s.downcase == 'true' : nil),
74
+ ),
75
+ ),
79
76
  )
80
77
 
81
78
  dot = ui.color('.', :magenta)
82
79
  api_client.wait_for { print dot; is_done? get_request_id headers }
83
80
 
84
- nic = nic_api.datacenters_servers_nics_find_by_id(
85
- config[:datacenter_id],
81
+ print_nic(nic_api.datacenters_servers_nics_find_by_id(
82
+ config[:datacenter_id],
86
83
  config[:server_id],
87
84
  nic.id,
88
- )
89
-
90
- puts "\n"
91
- puts "#{ui.color('ID', :cyan)}: #{nic.id}"
92
- puts "#{ui.color('Name', :cyan)}: #{nic.properties.name}"
93
- puts "#{ui.color('IPs', :cyan)}: #{nic.properties.ips.to_s}"
94
- puts "#{ui.color('DHCP', :cyan)}: #{nic.properties.dhcp}"
95
- puts "#{ui.color('LAN', :cyan)}: #{nic.properties.lan}"
96
- puts "#{ui.color('NAT', :cyan)}: #{nic.properties.nat}"
97
-
98
- puts 'done'
85
+ ))
99
86
  end
100
87
  end
101
88
  end
@@ -15,7 +15,7 @@ class Chef
15
15
  option :server_id,
16
16
  short: '-S SERVER_ID',
17
17
  long: '--server-id SERVER_ID',
18
- description: 'The ID of the server assigned the NIC'
18
+ description: 'The ID of the server to which the NIC is assigned'
19
19
 
20
20
  attr_reader :description, :required_options
21
21
 
@@ -40,13 +40,8 @@ class Chef
40
40
  ui.error("Nic ID #{nic_id} not found. Skipping.")
41
41
  next
42
42
  end
43
-
44
- msg_pair('ID', nic.id)
45
- msg_pair('Name', nic.properties.name)
46
- msg_pair('IPs', nic.properties.ips)
47
- msg_pair('DHCP', nic.properties.dhcp)
48
- msg_pair('LAN', nic.properties.lan)
49
- msg_pair('NAT', nic.properties.nat)
43
+ print_nic(nic)
44
+ puts "\n"
50
45
 
51
46
  begin
52
47
  confirm('Do you really want to delete this Nic')
@@ -0,0 +1,47 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNicGet < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud nic 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 :server_id,
16
+ short: '-S SERVER_ID',
17
+ long: '--server-id SERVER_ID',
18
+ description: 'The ID of the server to which the NIC is assigned'
19
+
20
+ option :nic_id,
21
+ short: '-N NIC_ID',
22
+ long: '--nic-id NIC_ID',
23
+ description: 'ID of the load balancer'
24
+
25
+ attr_reader :description, :required_options
26
+
27
+ def initialize(args = [])
28
+ super(args)
29
+ @description =
30
+ 'Retrieves the attributes of a given NIC.'
31
+ @required_options = [:datacenter_id, :server_id, :nic_id, :ionoscloud_username, :ionoscloud_password]
32
+ end
33
+
34
+ def run
35
+ $stdout.sync = true
36
+ handle_extra_config
37
+ validate_required_params(@required_options, config)
38
+
39
+ print_nic(Ionoscloud::NicApi.new(api_client).datacenters_servers_nics_find_by_id(
40
+ config[:datacenter_id],
41
+ config[:server_id],
42
+ config[:nic_id],
43
+ ))
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,93 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNicUpdate < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud nic 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 :server_id,
16
+ short: '-S SERVER_ID',
17
+ long: '--server-id SERVER_ID',
18
+ description: 'The ID of the server to which the NIC is assigned'
19
+
20
+ option :nic_id,
21
+ short: '-N NIC_ID',
22
+ long: '--nic-id NIC_ID',
23
+ description: 'ID of the load balancer'
24
+
25
+ option :name,
26
+ short: '-n NAME',
27
+ long: '--name NAME',
28
+ description: 'Name of the NIC'
29
+
30
+ option :ips,
31
+ short: '-i IP[,IP,...]',
32
+ long: '--ips IP[,IP,...]',
33
+ description: 'IPs assigned to the NIC'
34
+
35
+ option :dhcp,
36
+ long: '--dhcp DHCP',
37
+ description: 'Set to false if you wish to disable DHCP'
38
+
39
+ option :lan,
40
+ short: '-l ID',
41
+ long: '--lan ID',
42
+ description: 'The LAN ID the NIC will reside on; if the LAN ID does not exist it will be created'
43
+
44
+ option :nat,
45
+ long: '--nat NAT',
46
+ description: 'Set to enable NAT on the NIC'
47
+
48
+ attr_reader :description, :required_options
49
+
50
+ def initialize(args = [])
51
+ super(args)
52
+ @description =
53
+ 'Updates information about a Ionoscloud NIC.'
54
+ @required_options = [:datacenter_id, :server_id, :nic_id, :ionoscloud_username, :ionoscloud_password]
55
+ @updatable_fields = [:name, :ips, :dhcp, :lan, :nat]
56
+ end
57
+
58
+ def run
59
+ $stdout.sync = true
60
+ handle_extra_config
61
+ validate_required_params(@required_options, config)
62
+
63
+ config[:ips] = config[:ips].split(',') if config[:ips] && config[:ips].instance_of?(String)
64
+
65
+ nic_api = Ionoscloud::NicApi.new(api_client)
66
+
67
+ if @updatable_fields.map { |el| config[el] }.any?
68
+ print "#{ui.color('Updating NIC...', :magenta)}"
69
+
70
+ _, _, headers = nic_api.datacenters_servers_nics_patch_with_http_info(
71
+ config[:datacenter_id],
72
+ config[:server_id],
73
+ config[:nic_id],
74
+ Ionoscloud::NicProperties.new(
75
+ name: config[:name],
76
+ ips: config[:ips],
77
+ dhcp: (config.key?(:dhcp) ? config[:dhcp].to_s.downcase == 'true' : nil),
78
+ lan: config[:lan],
79
+ nat: (config.key?(:nat) ? config[:nat].to_s.downcase == 'true' : nil),
80
+ ),
81
+ )
82
+
83
+ dot = ui.color('.', :magenta)
84
+ api_client.wait_for { print dot; is_done? get_request_id headers }
85
+ else
86
+ ui.warn("Nothing to update, please set one of the attributes #{@updatable_fields}.")
87
+ end
88
+
89
+ print_nic(nic_api.datacenters_servers_nics_find_by_id(config[:datacenter_id], config[:server_id], config[:nic_id]))
90
+ end
91
+ end
92
+ end
93
+ end
@@ -42,12 +42,7 @@ class Chef
42
42
  ui.error("K8s Node ID #{node_id} not found. Skipping.")
43
43
  next
44
44
  end
45
-
46
- msg_pair('ID', node.id)
47
- msg_pair('Name', node.properties.name)
48
- msg_pair('Public IP', node.properties.public_ip)
49
- msg_pair('K8s Version', node.properties.k8s_version)
50
- msg_pair('State', node.metadata.state)
45
+ print_k8s_node(node)
51
46
 
52
47
  puts "\n"
53
48
 
@@ -0,0 +1,47 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNodeGet < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud node get (options)'
9
+
10
+ option :cluster_id,
11
+ short: '-C CLUSTER_ID',
12
+ long: '--cluster-id CLUSTER_ID',
13
+ description: 'The ID of the K8s Cluster'
14
+
15
+ option :nodepool_id,
16
+ short: '-P NODEPOOL_ID',
17
+ long: '--nodepool-id NODEPOOL_ID',
18
+ description: 'The ID of the K8s Nodepool'
19
+
20
+ option :node_id,
21
+ short: '-N NODE_ID',
22
+ long: '--node-id NODE_ID',
23
+ description: 'ID of the load balancer'
24
+
25
+ attr_reader :description, :required_options
26
+
27
+ def initialize(args = [])
28
+ super(args)
29
+ @description =
30
+ 'Retrieves the attributes of a given K8S Node.'
31
+ @required_options = [:cluster_id, :nodepool_id, :node_id, :ionoscloud_username, :ionoscloud_password]
32
+ end
33
+
34
+ def run
35
+ $stdout.sync = true
36
+ handle_extra_config
37
+ validate_required_params(@required_options, config)
38
+
39
+ print_k8s_node(Ionoscloud::KubernetesApi.new(api_client).k8s_nodepools_nodes_find_by_id(
40
+ config[:cluster_id],
41
+ config[:nodepool_id],
42
+ config[:node_id],
43
+ ))
44
+ end
45
+ end
46
+ end
47
+ end
@@ -22,13 +22,12 @@ class Chef
22
22
  long: '--name NAME',
23
23
  description: 'Name of the Kubernetes node pool'
24
24
 
25
- option :version,
25
+ option :k8s_version,
26
26
  short: '-v VERSION',
27
27
  long: '--version VERSION',
28
- description: 'The version for the Kubernetes cluster.'
28
+ description: 'The version for the Kubernetes Nodepool.'
29
29
 
30
30
  option :maintenance_day,
31
- short: '-d MAINTENANCE_DAY',
32
31
  long: '--maintenance-day MAINTENANCE_DAY',
33
32
  description: 'Day Of the week when to perform the maintenance.'
34
33
 
@@ -91,6 +90,14 @@ class Chef
91
90
  'must contain one extra IP than maximum number of nodes could be. (nodeCount+1 if fixed '\
92
91
  'node amount or maxNodeCount+1 if auto scaling is used) The extra provided IP Will be used during rebuilding of nodes.'
93
92
 
93
+ option :labels,
94
+ long: '--labels LABEL [LABEL]',
95
+ description: 'map of labels attached to node pool'
96
+
97
+ option :annotations,
98
+ long: '--annotations ANNOTATION [ANNOTATION]',
99
+ description: 'map of annotations attached to node pool'
100
+
94
101
  attr_reader :description, :required_options
95
102
 
96
103
  def initialize(args = [])
@@ -100,7 +107,7 @@ class Chef
100
107
  "The Kubernetes cluster must be in state \"ACTIVE\" before creating a node pool.\n\n"\
101
108
  "The worker nodes within the node pools will be deployed into an existing data centers."
102
109
  @required_options = [
103
- :datacenter_id, :cluster_id, :name, :version, :node_count, :cpu_family, :cores, :ram,
110
+ :datacenter_id, :cluster_id, :name, :k8s_version, :node_count, :cpu_family, :cores, :ram,
104
111
  :availability_zone, :storage_type, :storage_size, :ionoscloud_username, :ionoscloud_password,
105
112
  ]
106
113
  end
@@ -115,59 +122,45 @@ class Chef
115
122
  kubernetes_api = Ionoscloud::KubernetesApi.new(api_client)
116
123
 
117
124
  config[:public_ips] = config[:public_ips].split(',') if config[:public_ips] && config[:public_ips].instance_of?(String)
125
+ config[:lans] = config[:lans].split(',') if config[:lans] && config[:lans].instance_of?(String)
126
+ config[:labels] = JSON[config[:labels]] if config[:labels] && config[:labels].instance_of?(String)
127
+ config[:annotations] = JSON[config[:annotations]] if config[:annotations] && config[:annotations].instance_of?(String)
118
128
 
119
129
  nodepool_properties = {
120
130
  name: config[:name],
121
- k8sVersion: config[:version],
122
- datacenterId: config[:datacenter_id],
123
- nodeCount: config[:node_count],
124
- cpuFamily: config[:cpu_family],
125
- coresCount: config[:cores],
126
- ramSize: config[:ram],
127
- availabilityZone: config[:availability_zone],
128
- storageType: config[:storage_type],
129
- storageSize: config[:storage_size],
130
- publicIps: config[:public_ips],
131
+ k8s_version: config[:k8s_version],
132
+ datacenter_id: config[:datacenter_id],
133
+ node_count: config[:node_count],
134
+ cpu_family: config[:cpu_family],
135
+ cores_count: config[:cores],
136
+ ram_size: config[:ram],
137
+ availability_zone: config[:availability_zone],
138
+ storage_type: config[:storage_type],
139
+ storage_size: config[:storage_size],
140
+ public_ips: config[:public_ips],
141
+ labels: config[:labels],
142
+ annotations: config[:annotations],
143
+ lans: config.key?(:lans) ? config[:lans].map! { |lan| { id: Integer(lan) } } : nil,
144
+ auto_scaling: Ionoscloud::KubernetesAutoScaling.new(
145
+ min_node_count: config[:min_node_count],
146
+ max_node_count: config[:max_node_count],
147
+ ),
148
+ maintenance_window: (config.key?(:maintenance_day) || config.key?(:maintenance_time)) ? Ionoscloud::KubernetesMaintenanceWindow.new(
149
+ day_of_the_week: config[:maintenance_day],
150
+ time: config[:maintenance_time],
151
+ ) : nil,
131
152
  }
132
153
 
133
- if config[:maintenance_day] && config[:maintenance_time]
134
- nodepool_properties[:maintenanceWindow] = {
135
- dayOfTheWeek: config[:maintenance_day],
136
- time: config[:maintenance_time],
137
- }
138
- end
139
-
140
- if config[:min_node_count] || config[:max_node_count]
141
- nodepool_properties[:autoScaling] = {}
142
- nodepool_properties[:autoScaling][:minNodeCount] = config[:min_node_count] unless config[:min_node_count].nil?
143
- nodepool_properties[:autoScaling][:maxNodeCount] = config[:max_node_count] unless config[:max_node_count].nil?
144
- end
145
-
146
- if config[:lans]
147
- nodepool_properties[:lans] = config[:lans].split(',').map! { |lan| { id: Integer(lan) } }
148
- end
149
-
150
- nodepool = kubernetes_api.k8s_nodepools_post(config[:cluster_id], { properties: nodepool_properties })
151
-
152
- auto_scaling = "Min node count: #{nodepool.properties.auto_scaling.min_node_count}, Max node count:#{nodepool.properties.auto_scaling.max_node_count}"
153
- maintenance_window = "#{nodepool.properties.maintenance_window.day_of_the_week}, #{nodepool.properties.maintenance_window.time}"
154
-
155
- puts "\n"
156
- puts "#{ui.color('ID', :cyan)}: #{nodepool.id}"
157
- puts "#{ui.color('Name', :cyan)}: #{nodepool.properties.name}"
158
- puts "#{ui.color('K8s Version', :cyan)}: #{nodepool.properties.k8s_version}"
159
- puts "#{ui.color('Datacenter ID', :cyan)}: #{nodepool.properties.datacenter_id}"
160
- puts "#{ui.color('Node Count', :cyan)}: #{nodepool.properties.node_count}"
161
- puts "#{ui.color('CPU Family', :cyan)}: #{nodepool.properties.cpu_family}"
162
- puts "#{ui.color('Cores Count', :cyan)}: #{nodepool.properties.cores_count}"
163
- puts "#{ui.color('RAM', :cyan)}: #{nodepool.properties.ram_size}"
164
- puts "#{ui.color('Storage Type', :cyan)}: #{nodepool.properties.storage_type}"
165
- puts "#{ui.color('Storage Size', :cyan)}: #{nodepool.properties.storage_size}"
166
- puts "#{ui.color('Availability Zone', :cyan)}: #{nodepool.properties.availability_zone}"
167
- puts "#{ui.color('Auto Scaling', :cyan)}: #{auto_scaling}"
168
- puts "#{ui.color('Maintenance Window', :cyan)}: #{maintenance_window}"
169
- puts "#{ui.color('State', :cyan)}: #{nodepool.metadata.state}"
170
- puts 'done'
154
+ print_k8s_nodepool(
155
+ kubernetes_api.k8s_nodepools_post(
156
+ config[:cluster_id],
157
+ Ionoscloud::KubernetesNodePoolForPost.new(
158
+ properties: Ionoscloud::KubernetesNodePoolPropertiesForPost.new(
159
+ **nodepool_properties,
160
+ ),
161
+ ),
162
+ ),
163
+ )
171
164
  end
172
165
  end
173
166
  end
@@ -37,13 +37,7 @@ class Chef
37
37
  next
38
38
  end
39
39
 
40
- msg_pair('ID', nodepool.id)
41
- msg_pair('Name', nodepool.properties.name)
42
- msg_pair('K8s Version', nodepool.properties.k8s_version)
43
- msg_pair('Datacenter ID', nodepool.properties.datacenter_id)
44
- msg_pair('Node Count', nodepool.properties.node_count)
45
- msg_pair('State', nodepool.metadata.state)
46
-
40
+ print_k8s_nodepool(nodepool)
47
41
  puts "\n"
48
42
 
49
43
  begin
@@ -0,0 +1,41 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNodepoolGet < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud nodepool get (options)'
9
+
10
+ option :cluster_id,
11
+ short: '-C CLUSTER_ID',
12
+ long: '--cluster-id CLUSTER_ID',
13
+ description: 'The ID of the K8s Cluster'
14
+
15
+ option :nodepool_id,
16
+ short: '-P NODEPOOL_ID',
17
+ long: '--nodepool-id NODEPOOL_ID',
18
+ description: 'The ID of the K8s Nodepool'
19
+
20
+ attr_reader :description, :required_options
21
+
22
+ def initialize(args = [])
23
+ super(args)
24
+ @description =
25
+ 'Retrieves the attributes of a given K8S Nodepool.'
26
+ @required_options = [:cluster_id, :nodepool_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_k8s_nodepool(Ionoscloud::KubernetesApi.new(api_client).k8s_nodepools_find_by_id(
35
+ config[:cluster_id],
36
+ config[:nodepool_id],
37
+ ))
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,124 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudNodepoolUpdate < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud nodepool update (options)'
9
+
10
+ option :cluster_id,
11
+ short: '-C CLUSTER_ID',
12
+ long: '--cluster-id CLUSTER_ID',
13
+ description: 'ID of the Kubernetes cluster'
14
+
15
+ option :nodepool_id,
16
+ short: '-P NODEPOOL_ID',
17
+ long: '--nodepool-id NODEPOOL_ID',
18
+ description: 'ID of the Kubernetes nodepool'
19
+
20
+ option :k8s_version,
21
+ short: '-v VERSION',
22
+ long: '--version VERSION',
23
+ description: 'The version for the Kubernetes cluster.'
24
+
25
+ option :maintenance_day,
26
+ long: '--maintenance-day MAINTENANCE_DAY',
27
+ description: 'Day Of the week when to perform the maintenance.'
28
+
29
+ option :maintenance_time,
30
+ short: '-t MAINTENANCE_TIME',
31
+ long: '--maintenance-time MAINTENANCE_TIME',
32
+ description: 'Time Of the day when to perform the maintenance.'
33
+
34
+ option :node_count,
35
+ short: '-c NODE_COUNT',
36
+ long: '--node-count NODE_COUNT',
37
+ description: 'The number of worker nodes that the node pool should contain. Min 2, Max: Determined by the resource availability.'
38
+
39
+ option :min_node_count,
40
+ long: '--min-node-count MIN_NODE_COUNT',
41
+ description: 'The minimum number of worker nodes that the managed node group can scale in'
42
+
43
+ option :max_node_count,
44
+ long: '--max-node-count MAX_NODE_COUNT',
45
+ description: 'The maximum number of worker nodes that the managed node pool can scale-out.'
46
+
47
+ option :lans,
48
+ long: '--lans LAN_ID [LAN_ID]',
49
+ description: 'An array of additional private LANs attached to worker nodes'
50
+
51
+ option :public_ips,
52
+ long: '--ips PUBLIC_IP [PUBLIC_IP]',
53
+ description: 'Optional array of reserved public IP addresses to be used by the nodes. '\
54
+ 'IPs must be from same location as the data center used for the node pool. The array '\
55
+ 'must contain one extra IP than maximum number of nodes could be. (nodeCount+1 if fixed '\
56
+ 'node amount or maxNodeCount+1 if auto scaling is used) The extra provided IP Will be used during rebuilding of nodes.'
57
+
58
+ option :labels,
59
+ long: '--labels LABEL [LABEL]',
60
+ description: 'map of labels attached to node pool'
61
+
62
+ option :annotations,
63
+ long: '--annotations ANNOTATION [ANNOTATION]',
64
+ description: 'map of annotations attached to node pool'
65
+
66
+ attr_reader :description, :required_options
67
+
68
+ def initialize(args = [])
69
+ super(args)
70
+ @description =
71
+ 'Updates information about a Ionoscloud K8s Nodepool.'
72
+ @required_options = [:cluster_id, :nodepool_id, :ionoscloud_username, :ionoscloud_password]
73
+ @updatable_fields = [
74
+ :k8s_version, :node_count, :public_ips, :lans, :maintenance_day, :maintenance_time,
75
+ :min_node_count, :max_node_count, :labels, :annotations,
76
+ ]
77
+ end
78
+
79
+ def run
80
+ $stdout.sync = true
81
+ handle_extra_config
82
+ validate_required_params(@required_options, config)
83
+
84
+ config[:public_ips] = config[:public_ips].split(',') if config[:public_ips] && config[:public_ips].instance_of?(String)
85
+ config[:lans] = config[:lans].split(',') if config[:lans] && config[:lans].instance_of?(String)
86
+ config[:labels] = JSON[config[:labels]] if config[:labels] && config[:labels].instance_of?(String)
87
+ config[:annotations] = JSON[config[:annotations]] if config[:annotations] && config[:annotations].instance_of?(String)
88
+
89
+ kubernetes_api = Ionoscloud::KubernetesApi.new(api_client)
90
+
91
+ if @updatable_fields.map { |el| config[el] }.any?
92
+ print "#{ui.color('Updating K8s Nodepool...', :magenta)}"
93
+
94
+ nodepool = kubernetes_api.k8s_nodepools_find_by_id(config[:cluster_id], config[:nodepool_id])
95
+
96
+ new_nodepool = Ionoscloud::KubernetesNodePoolForPut.new(
97
+ properties: Ionoscloud::KubernetesNodePoolPropertiesForPut.new(
98
+ k8s_version: config.key?(:k8s_version) ? config[:k8s_version] : nodepool.properties.k8s_version,
99
+ node_count: config.key?(:node_count) ? config[:node_count] : nodepool.properties.node_count,
100
+ public_ips: config.key?(:public_ips) ? config[:public_ips] : nodepool.properties.public_ips,
101
+ labels: config.key?(:labels) ? config[:labels] : nodepool.properties.labels,
102
+ annotations: config.key?(:annotations) ? config[:annotations] : nodepool.properties.annotations,
103
+ lans: config.key?(:lans) ? config[:lans].map! { |lan| { id: Integer(lan) } } : nodepool.properties.lans,
104
+ maintenance_window: Ionoscloud::KubernetesMaintenanceWindow.new(
105
+ day_of_the_week: config.key?(:maintenance_day) ? config[:maintenance_day] : nodepool.properties.maintenance_window.day_of_the_week,
106
+ time: config.key?(:maintenance_time) ? config[:maintenance_time] : nodepool.properties.maintenance_window.time,
107
+ ),
108
+ auto_scaling: Ionoscloud::KubernetesAutoScaling.new(
109
+ min_node_count: config.key?(:min_node_count) ? config[:min_node_count] : nodepool.properties.auto_scaling.min_node_count,
110
+ max_node_count: config.key?(:max_node_count) ? config[:max_node_count] : nodepool.properties.auto_scaling.max_node_count,
111
+ ),
112
+ ),
113
+ )
114
+
115
+ kubernetes_api.k8s_nodepools_put(config[:cluster_id], config[:nodepool_id], new_nodepool)
116
+ else
117
+ ui.warn("Nothing to update, please set one of the attributes #{@updatable_fields}.")
118
+ end
119
+
120
+ print_k8s_nodepool(kubernetes_api.k8s_nodepools_find_by_id(config[:cluster_id], config[:nodepool_id]))
121
+ end
122
+ end
123
+ end
124
+ end
@@ -45,12 +45,14 @@ class Chef
45
45
  exit(1)
46
46
  end
47
47
 
48
- pcc, _, headers = pcc_api.pccs_post_with_http_info({
49
- properties: {
50
- name: config[:name],
51
- description: config[:description],
52
- }.compact,
53
- })
48
+ pcc, _, headers = pcc_api.pccs_post_with_http_info(
49
+ Ionoscloud::PrivateCrossConnect.new(
50
+ properties: Ionoscloud::PrivateCrossConnectProperties.new(
51
+ name: config[:name],
52
+ description: config[:description],
53
+ ),
54
+ ),
55
+ )
54
56
 
55
57
  dot = ui.color('.', :magenta)
56
58
  api_client.wait_for { print dot; is_done? get_request_id headers }
@@ -70,7 +72,7 @@ class Chef
70
72
  _, _, headers = lan_api.datacenters_lans_patch_with_http_info(
71
73
  datacenter_id,
72
74
  lan_id,
73
- { pcc: pcc.id },
75
+ Ionoscloud::LanProperties.new(pcc: pcc.id),
74
76
  )
75
77
  header_list << headers
76
78
  end
@@ -81,15 +83,7 @@ class Chef
81
83
  end
82
84
  end
83
85
 
84
- pcc = pcc_api.pccs_find_by_id(pcc.id)
85
-
86
- puts "\n"
87
- puts "#{ui.color('ID', :cyan)}: #{pcc.id}"
88
- puts "#{ui.color('Name', :cyan)}: #{pcc.properties.name}"
89
- puts "#{ui.color('Description', :cyan)}: #{pcc.properties.description}"
90
- puts "#{ui.color('Peers', :cyan)}: #{pcc.properties.peers.to_s}"
91
- puts "#{ui.color('Datacenters', :cyan)}: #{pcc.properties.connectable_datacenters.to_s}"
92
- puts 'done'
86
+ print_pcc(pcc_api.pccs_find_by_id(pcc.id))
93
87
  end
94
88
  end
95
89
  end