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
@@ -97,32 +97,7 @@ class Chef
97
97
  ui.info("Adding Lan #{config[:lan_id]} to the Nodepoool.")
98
98
  end
99
99
 
100
- auto_scaling = "Min node count: #{nodepool.properties.auto_scaling.min_node_count}, Max node count:#{nodepool.properties.auto_scaling.max_node_count}"
101
- maintenance_window = "#{nodepool.properties.maintenance_window.day_of_the_week}, #{nodepool.properties.maintenance_window.time}"
102
-
103
- puts "\n"
104
- puts "#{ui.color('ID', :cyan)}: #{nodepool.id}"
105
- puts "#{ui.color('Name', :cyan)}: #{nodepool.properties.name}"
106
- puts "#{ui.color('K8s Version', :cyan)}: #{nodepool.properties.k8s_version}"
107
- puts "#{ui.color('Node Count', :cyan)}: #{nodepool.properties.node_count}"
108
- puts "#{ui.color('Lans', :cyan)}: #{nodepool.properties.lans.map do
109
- |lan|
110
- {
111
- id: lan.id,
112
- dhcp: lan.dhcp,
113
- routes: lan.routes ? lan.routes.map do
114
- |route|
115
- {
116
- network: route.network,
117
- gateway_ip: route.gateway_ip,
118
- }
119
- end : []
120
- }
121
- end}"
122
- puts "#{ui.color('Auto Scaling', :cyan)}: #{auto_scaling}"
123
- puts "#{ui.color('Maintenance Window', :cyan)}: #{maintenance_window}"
124
- puts "#{ui.color('State', :cyan)}: #{nodepool.metadata.state}"
125
- puts 'done'
100
+ print_k8s_nodepool(nodepool)
126
101
  end
127
102
  end
128
103
  end
@@ -65,32 +65,7 @@ class Chef
65
65
  ui.info("None of the specified Lan IDs (#{@name_args}) are present on the Nodepoool.")
66
66
  end
67
67
 
68
- auto_scaling = "Min node count: #{nodepool.properties.auto_scaling.min_node_count}, Max node count:#{nodepool.properties.auto_scaling.max_node_count}"
69
- maintenance_window = "#{nodepool.properties.maintenance_window.day_of_the_week}, #{nodepool.properties.maintenance_window.time}"
70
-
71
- puts "\n"
72
- puts "#{ui.color('ID', :cyan)}: #{nodepool.id}"
73
- puts "#{ui.color('Name', :cyan)}: #{nodepool.properties.name}"
74
- puts "#{ui.color('K8s Version', :cyan)}: #{nodepool.properties.k8s_version}"
75
- puts "#{ui.color('Node Count', :cyan)}: #{nodepool.properties.node_count}"
76
- puts "#{ui.color('Lans', :cyan)}: #{nodepool.properties.lans.map do
77
- |lan|
78
- {
79
- id: lan.id,
80
- dhcp: lan.dhcp,
81
- routes: lan.routes ? lan.routes.map do
82
- |route|
83
- {
84
- network: route.network,
85
- gateway_ip: route.gateway_ip,
86
- }
87
- end : []
88
- }
89
- end}"
90
- puts "#{ui.color('Auto Scaling', :cyan)}: #{auto_scaling}"
91
- puts "#{ui.color('Maintenance Window', :cyan)}: #{maintenance_window}"
92
- puts "#{ui.color('State', :cyan)}: #{nodepool.metadata.state}"
93
- puts 'done'
68
+ print_k8s_nodepool(nodepool)
94
69
  end
95
70
  end
96
71
  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 }
@@ -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
@@ -32,15 +32,7 @@ class Chef
32
32
  next
33
33
  end
34
34
 
35
- peers = pcc.properties.peers.map { |peer| peer.id }
36
- datacenters = pcc.properties.connectable_datacenters.map { |datacenter| datacenter.id }
37
-
38
- msg_pair('ID', pcc.id)
39
- msg_pair('Name', pcc.properties.name)
40
- msg_pair('Description', pcc.properties.description)
41
- msg_pair('Peers', peers.to_s)
42
- msg_pair('Datacenters', datacenters.to_s)
43
-
35
+ print_pcc(pcc)
44
36
  puts "\n"
45
37
 
46
38
  begin
@@ -0,0 +1,33 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudPccGet < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud pcc get (options)'
9
+
10
+ option :pcc_id,
11
+ short: '-P PRIVATE_CROSS_CONNECT_ID',
12
+ long: '--pcc-id PRIVATE_CROSS_CONNECT_ID',
13
+ description: 'ID of the Private Cross Connect'
14
+
15
+ attr_reader :description, :required_options
16
+
17
+ def initialize(args = [])
18
+ super(args)
19
+ @description =
20
+ 'Retrieves information about a Ionoscloud Private Cross Connect.'
21
+ @required_options = [:pcc_id, :ionoscloud_username, :ionoscloud_password]
22
+ end
23
+
24
+ def run
25
+ $stdout.sync = true
26
+ handle_extra_config
27
+ validate_required_params(@required_options, config)
28
+
29
+ print_pcc(Ionoscloud::PrivateCrossConnectsApi.new(api_client).pccs_find_by_id(config[:pcc_id]))
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,63 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudPccUpdate < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud pcc update (options)'
9
+
10
+ option :pcc_id,
11
+ short: '-P PRIVATE_CROSS_CONNECT_ID',
12
+ long: '--pcc-id PRIVATE_CROSS_CONNECT_ID',
13
+ description: 'ID of the Private Cross Connect'
14
+
15
+ option :name,
16
+ short: '-n NAME',
17
+ long: '--name NAME',
18
+ description: 'Name of the data center'
19
+
20
+ option :description,
21
+ long: '--description DESCRIPTION',
22
+ description: 'Description of the data center'
23
+
24
+ attr_reader :description, :required_options
25
+
26
+ def initialize(args = [])
27
+ super(args)
28
+ @description =
29
+ 'Updates information about a Ionoscloud Private Cross Connect. In order to add LANs to the Private Cross Connect one should'\
30
+ 'update the LAN and change the pcc property using the ```text\knife ionscloud lan update\n``` command.'
31
+ @required_options = [:pcc_id, :ionoscloud_username, :ionoscloud_password]
32
+ @updatable_fields = [:name, :description]
33
+ end
34
+
35
+ def run
36
+ $stdout.sync = true
37
+ handle_extra_config
38
+ validate_required_params(@required_options, config)
39
+
40
+ pcc_api = Ionoscloud::PrivateCrossConnectsApi.new(api_client)
41
+
42
+ if @updatable_fields.map { |el| config[el] }.any?
43
+ print "#{ui.color('Updating Private Cross Connect...', :magenta)}"
44
+
45
+ _, _, headers = pcc_api.pccs_patch_with_http_info(
46
+ config[:pcc_id],
47
+ Ionoscloud::PrivateCrossConnectProperties.new(
48
+ name: config[:name],
49
+ description: config[:description],
50
+ )
51
+ )
52
+
53
+ dot = ui.color('.', :magenta)
54
+ api_client.wait_for { print dot; is_done? get_request_id headers }
55
+ else
56
+ ui.warn("Nothing to update, please set one of the attributes #{@updatable_fields}.")
57
+ end
58
+
59
+ print_pcc(pcc_api.pccs_find_by_id(config[:pcc_id]))
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,40 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudRequestGet < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud request get (options)'
9
+
10
+ option :request_id,
11
+ short: '-R REQUEST_ID',
12
+ long: '--request-id REQUEST_ID',
13
+ description: 'The ID of the Request.'
14
+
15
+ attr_reader :description, :required_options
16
+
17
+ def initialize(args = [])
18
+ super(args)
19
+ @description =
20
+ 'Retrieves the properties of a specific request based on the supplied request id.'
21
+ @required_options = [:request_id, :ionoscloud_username, :ionoscloud_password]
22
+ end
23
+
24
+ def run
25
+ $stdout.sync = true
26
+ handle_extra_config
27
+ validate_required_params(@required_options, config)
28
+
29
+ request = Ionoscloud::RequestsApi.new(api_client).requests_find_by_id(config[:request_id], depth: 1)
30
+ puts "#{ui.color('ID', :cyan)}: #{request.id}"
31
+ puts "#{ui.color('Status', :cyan)}: #{request.metadata.request_status.metadata.status}"
32
+ puts "#{ui.color('Method', :cyan)}: #{request.properties.method}"
33
+ puts "#{ui.color('URL', :cyan)}: #{request.properties.url}"
34
+ puts "#{ui.color('Targets', :cyan)}: #{request.metadata.request_status.metadata.targets.map { |target| [target.target.id, target.target.type] }.to_s}"
35
+ puts "#{ui.color('Body', :cyan)}: #{request.properties.body}"
36
+ puts "#{ui.color('Headers', :cyan)}: #{request.properties.headers}"
37
+ end
38
+ end
39
+ end
40
+ end
@@ -35,11 +35,7 @@ class Chef
35
35
  dot = ui.color('.', :magenta)
36
36
  api_client.wait_for { print dot; is_done? get_request_id headers }
37
37
 
38
- puts "\n"
39
- puts "#{ui.color('ID', :cyan)}: #{s3_key.id}"
40
- puts "#{ui.color('Secret Key', :cyan)}: #{s3_key.properties.secret_key}"
41
- puts "#{ui.color('Active', :cyan)}: #{s3_key.properties.active}"
42
- puts 'done'
38
+ print_s3key(s3_key)
43
39
  end
44
40
  end
45
41
  end
@@ -37,10 +37,7 @@ class Chef
37
37
  next
38
38
  end
39
39
 
40
- msg_pair('ID', s3_key.id)
41
- msg_pair('Secret Key', s3_key.properties.secret_key)
42
- msg_pair('Active', s3_key.properties.active.to_s)
43
-
40
+ print_s3key(s3_key)
44
41
  puts "\n"
45
42
 
46
43
  begin
@@ -0,0 +1,38 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudS3keyGet < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud s3key get (options)'
9
+
10
+ option :user_id,
11
+ short: '-u USER_ID',
12
+ long: '--user USER_ID',
13
+ description: 'The ID of the user'
14
+
15
+ option :s3_key_id,
16
+ short: '-S S3KEY_ID',
17
+ long: '--s3-key S3KEY_ID',
18
+ description: 'The ID of the S3 Key.'
19
+
20
+ attr_reader :description, :required_options
21
+
22
+ def initialize(args = [])
23
+ super(args)
24
+ @description =
25
+ 'Retrieves the properties of an S3 Key.'
26
+ @required_options = [:user_id, :s3_key_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_s3key(Ionoscloud::UserS3KeysApi.new(api_client).um_users_s3keys_find_by_key_id(config[:user_id], config[:s3_key_id]))
35
+ end
36
+ end
37
+ end
38
+ end
@@ -65,40 +65,28 @@ class Chef
65
65
  validate_required_params(@required_options, config)
66
66
 
67
67
  print "#{ui.color('Creating server...', :magenta)}"
68
- params = {
69
- name: config[:name],
70
- cores: config[:cores],
71
- cpu_family: config[:cpu_family],
72
- ram: config[:ram],
73
- availability_zone: config[:availability_zone],
74
- }
75
-
76
- params[:boot_cdrom] = { id: config[:boot_cdrom] } unless config[:boot_cdrom].nil?
77
- params[:boot_volume] = { id: config[:boot_volume] } unless config[:boot_volume].nil?
78
68
 
79
69
  servers_api = Ionoscloud::ServersApi.new(api_client)
80
70
 
81
71
  server, _, headers = servers_api.datacenters_servers_post_with_http_info(
82
72
  config[:datacenter_id],
83
- Ionoscloud::Server.new(properties: Ionoscloud::ServerProperties.new(params.compact)),
73
+ Ionoscloud::Server.new(
74
+ properties: Ionoscloud::ServerProperties.new(
75
+ name: config[:name],
76
+ cores: config[:cores],
77
+ cpu_family: config[:cpu_family],
78
+ ram: config[:ram],
79
+ availability_zone: config[:availability_zone],
80
+ boot_cdrom: config.key?(:boot_cdrom) ? { id: config[:boot_cdrom] } : nil,
81
+ boot_volume: config.key?(:boot_volume) ? { id: config[:boot_volume] } : nil,
82
+ ),
83
+ ),
84
84
  )
85
85
 
86
86
  dot = ui.color('.', :magenta)
87
87
  api_client.wait_for { print dot; is_done? get_request_id headers }
88
88
 
89
- server = servers_api.datacenters_servers_find_by_id(config[:datacenter_id], server.id)
90
-
91
- puts "\n"
92
- puts "#{ui.color('ID', :cyan)}: #{server.id}"
93
- puts "#{ui.color('Name', :cyan)}: #{server.properties.name}"
94
- puts "#{ui.color('Cores', :cyan)}: #{server.properties.cores}"
95
- puts "#{ui.color('CPU Family', :cyan)}: #{server.properties.cpu_family}"
96
- puts "#{ui.color('Ram', :cyan)}: #{server.properties.ram}"
97
- puts "#{ui.color('Availability Zone', :cyan)}: #{server.properties.availability_zone}"
98
- puts "#{ui.color('Boot Volume', :cyan)}: #{server.properties.boot_volume ? server.properties.boot_volume.id : ''}"
99
- puts "#{ui.color('Boot CDROM', :cyan)}: #{server.properties.boot_cdrom ? server.properties.boot_cdrom.id : ''}"
100
-
101
- puts 'done'
89
+ print_server(servers_api.datacenters_servers_find_by_id(config[:datacenter_id], server.id))
102
90
  end
103
91
  end
104
92
  end
@@ -39,14 +39,8 @@ class Chef
39
39
  next
40
40
  end
41
41
 
42
- msg_pair('ID', server.id)
43
- msg_pair('Name', server.properties.name)
44
- msg_pair('Cores', server.properties.cores)
45
- msg_pair('CPU Family', server.properties.cpu_family)
46
- msg_pair('Ram', server.properties.ram)
47
- msg_pair('Availability Zone', server.properties.availability_zone)
48
- msg_pair('Boot Volume', (server.properties.boot_volume.nil? ? '' : server.properties.boot_volume.id))
49
- msg_pair('Boot CDROM', (server.properties.boot_cdrom.nil? ? '' : server.properties.boot_cdrom.id))
42
+ print_server(server)
43
+ puts "\n"
50
44
 
51
45
  begin
52
46
  confirm('Do you really want to delete this server')
@@ -0,0 +1,43 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudServerGet < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud server 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
+ attr_reader :description, :required_options
21
+
22
+ def initialize(args = [])
23
+ super(args)
24
+ @description =
25
+ 'Retrieves the attributes of a given Server.'
26
+ @required_options = [:datacenter_id, :server_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_server(
35
+ Ionoscloud::ServersApi.new(api_client).datacenters_servers_find_by_id(
36
+ config[:datacenter_id],
37
+ config[:server_id],
38
+ ),
39
+ )
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,97 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudServerUpdate < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud server 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 :name,
21
+ short: '-n NAME',
22
+ long: '--name NAME',
23
+ description: 'Name of the server'
24
+
25
+ option :cores,
26
+ short: '-C CORES',
27
+ long: '--cores CORES',
28
+ description: 'The number of processor cores'
29
+
30
+ option :cpu_family,
31
+ short: '-f CPU_FAMILY',
32
+ long: '--cpu-family CPU_FAMILY',
33
+ description: 'The family of the CPU (INTEL_XEON or AMD_OPTERON)'
34
+
35
+ option :ram,
36
+ short: '-r RAM',
37
+ long: '--ram RAM',
38
+ description: 'The amount of RAM in MB'
39
+
40
+ option :availability_zone,
41
+ short: '-a AVAILABILITY_ZONE',
42
+ long: '--availability-zone AVAILABILITY_ZONE',
43
+ description: 'The availability zone of the server'
44
+
45
+ option :boot_volume,
46
+ long: '--boot-volume VOLUME_ID',
47
+ description: 'Reference to a volume used for booting'
48
+
49
+ option :boot_cdrom,
50
+ long: '--boot-cdrom CDROM_ID',
51
+ description: 'Reference to a CD-ROM used for booting'
52
+
53
+ attr_reader :description, :required_options
54
+
55
+ def initialize(args = [])
56
+ super(args)
57
+ @description =
58
+ 'Updates information about a Ionoscloud Server.'
59
+ @required_options = [:datacenter_id, :server_id, :ionoscloud_username, :ionoscloud_password]
60
+ @updatable_fields = [:name, :cores, :cpu_family, :ram, :availability_zone, :boot_volume, :boot_cdrom]
61
+ end
62
+
63
+ def run
64
+ $stdout.sync = true
65
+ handle_extra_config
66
+ validate_required_params(@required_options, config)
67
+
68
+ server_api = Ionoscloud::ServersApi.new(api_client)
69
+
70
+ if @updatable_fields.map { |el| config[el] }.any?
71
+ print "#{ui.color('Updating Server...', :magenta)}"
72
+
73
+ _, _, headers = server_api.datacenters_servers_patch_with_http_info(
74
+ config[:datacenter_id],
75
+ config[:server_id],
76
+ Ionoscloud::ServerProperties.new(
77
+ name: config[:name],
78
+ cores: config[:cores],
79
+ cpu_family: config[:cpu_family],
80
+ ram: config[:ram],
81
+ availability_zone: config[:availability_zone],
82
+ boot_cdrom: config.key?(:boot_cdrom) ? { id: config[:boot_cdrom] } : nil,
83
+ boot_volume: config.key?(:boot_volume) ? { id: config[:boot_volume] } : nil,
84
+ ),
85
+ )
86
+
87
+ dot = ui.color('.', :magenta)
88
+ api_client.wait_for { print dot; is_done? get_request_id headers }
89
+ else
90
+ ui.warn("Nothing to update, please set one of the attributes #{@updatable_fields}.")
91
+ end
92
+
93
+ print_server(server_api.datacenters_servers_find_by_id(config[:datacenter_id], config[:server_id]))
94
+ end
95
+ end
96
+ end
97
+ end