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
@@ -0,0 +1,109 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_group_update'
3
+
4
+ Chef::Knife::IonoscloudGroupUpdate.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudGroupUpdate do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudGroupUpdate.new }
9
+
10
+ allow(subject).to receive(:puts)
11
+ allow(subject).to receive(:print)
12
+ end
13
+
14
+ describe '#run' do
15
+ it 'should call UserManagementApi.um_groups_put' do
16
+ group = group_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ group_id: group.id,
21
+ name: group.properties.name + '_edited',
22
+ create_snapshot: !group.properties.create_snapshot,
23
+ reserve_ip: group.properties.reserve_ip,
24
+ access_activity_log: !group.properties.access_activity_log,
25
+ create_backup_unit: !group.properties.create_backup_unit,
26
+ create_pcc: !group.properties.create_pcc,
27
+ yes: true,
28
+ }
29
+
30
+ subject_config.each { |key, value| subject.config[key] = value }
31
+
32
+ expect(subject).to receive(:puts).with("ID: #{group.id}")
33
+ expect(subject).to receive(:puts).with("Name: #{subject_config[:name]}")
34
+ expect(subject).to receive(:puts).with("Create Datacenter: #{group.properties.create_data_center.to_s}")
35
+ expect(subject).to receive(:puts).with("Create Snapshot: #{subject_config[:create_snapshot].to_s}")
36
+ expect(subject).to receive(:puts).with("Reserve IP: #{group.properties.reserve_ip.to_s}")
37
+ expect(subject).to receive(:puts).with("Access Activity Log: #{subject_config[:access_activity_log].to_s}")
38
+ expect(subject).to receive(:puts).with("S3 Privilege: #{group.properties.s3_privilege.to_s}")
39
+ expect(subject).to receive(:puts).with("Create Backup Unit: #{subject_config[:create_backup_unit].to_s}")
40
+ expect(subject).to receive(:puts).with("Create K8s Clusters: #{group.properties.create_k8s_cluster.to_s}")
41
+ expect(subject).to receive(:puts).with("Create PCC: #{subject_config[:create_pcc].to_s}")
42
+ expect(subject).to receive(:puts).with("Create Internet Acess: #{group.properties.create_internet_access.to_s}")
43
+
44
+ group.properties.name = subject_config[:name]
45
+ group.properties.create_snapshot = subject_config[:create_snapshot]
46
+ group.properties.access_activity_log = subject_config[:access_activity_log]
47
+ group.properties.create_backup_unit = subject_config[:create_backup_unit]
48
+ group.properties.create_pcc = subject_config[:create_pcc]
49
+
50
+ expected_body = {
51
+ name: subject_config[:name],
52
+ createSnapshot: subject_config[:create_snapshot],
53
+ reserveIp: subject_config[:reserve_ip],
54
+ accessActivityLog: subject_config[:access_activity_log],
55
+ createBackupUnit: subject_config[:create_backup_unit],
56
+ createPcc: subject_config[:create_pcc],
57
+ }.merge(group.properties.to_hash)
58
+
59
+ mock_wait_for(subject)
60
+ mock_call_api(
61
+ subject,
62
+ [
63
+ {
64
+ method: 'GET',
65
+ path: "/um/groups/#{group.id}",
66
+ operation: :'UserManagementApi.um_groups_find_by_id',
67
+ return_type: 'Group',
68
+ result: group,
69
+ },
70
+ {
71
+ method: 'PUT',
72
+ path: "/um/groups/#{group.id}",
73
+ operation: :'UserManagementApi.um_groups_put',
74
+ return_type: 'Group',
75
+ body: { properties: expected_body },
76
+ result: group,
77
+ },
78
+ {
79
+ method: 'GET',
80
+ path: "/um/groups/#{group.id}",
81
+ operation: :'UserManagementApi.um_groups_find_by_id',
82
+ return_type: 'Group',
83
+ result: group,
84
+ },
85
+ ],
86
+ )
87
+
88
+ expect { subject.run }.not_to raise_error(Exception)
89
+ end
90
+
91
+ it 'should not make any call if any required option is missing' do
92
+ required_options = subject.instance_variable_get(:@required_options)
93
+
94
+ arrays_without_one_element(required_options).each do |test_case|
95
+
96
+ test_case[:array].each { |value| subject.config[value] = 'test' }
97
+
98
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
99
+ expect(subject.api_client).not_to receive(:call_api)
100
+
101
+ expect { subject.run }.to raise_error(SystemExit) do |error|
102
+ expect(error.status).to eq(1)
103
+ end
104
+
105
+ required_options.each { |value| subject.config[value] = nil }
106
+ end
107
+ end
108
+ end
109
+ end
@@ -35,6 +35,9 @@ describe Chef::Knife::IonoscloudGroupUserAdd do
35
35
  expect(subject).to receive(:puts).with("Access Activity Log: #{group.properties.access_activity_log.to_s}")
36
36
  expect(subject).to receive(:puts).with("S3 Privilege: #{group.properties.s3_privilege.to_s}")
37
37
  expect(subject).to receive(:puts).with("Create Backup Unit: #{group.properties.create_backup_unit.to_s}")
38
+ expect(subject).to receive(:puts).with("Create K8s Clusters: #{group.properties.create_k8s_cluster.to_s}")
39
+ expect(subject).to receive(:puts).with("Create PCC: #{group.properties.create_pcc.to_s}")
40
+ expect(subject).to receive(:puts).with("Create Internet Acess: #{group.properties.create_internet_access.to_s}")
38
41
  expect(subject).to receive(:puts).with("Users: #{users.to_s}")
39
42
  expect(subject.ui).to receive(:info).with("Added User #{user.id} to the Group #{group.id}. Request ID: .")
40
43
 
@@ -35,6 +35,9 @@ describe Chef::Knife::IonoscloudGroupUserRemove do
35
35
  expect(subject).to receive(:puts).with("Access Activity Log: #{group.properties.access_activity_log.to_s}")
36
36
  expect(subject).to receive(:puts).with("S3 Privilege: #{group.properties.s3_privilege.to_s}")
37
37
  expect(subject).to receive(:puts).with("Create Backup Unit: #{group.properties.create_backup_unit.to_s}")
38
+ expect(subject).to receive(:puts).with("Create K8s Clusters: #{group.properties.create_k8s_cluster.to_s}")
39
+ expect(subject).to receive(:puts).with("Create PCC: #{group.properties.create_pcc.to_s}")
40
+ expect(subject).to receive(:puts).with("Create Internet Acess: #{group.properties.create_internet_access.to_s}")
38
41
  expect(subject).to receive(:puts).with("Users: #{users.to_s}")
39
42
  expect(subject.ui).to receive(:warn).with("Removed User #{user.id} from the Group #{group.id}. Request ID: .")
40
43
 
@@ -23,10 +23,12 @@ describe Chef::Knife::IonoscloudIpblockDelete do
23
23
  subject_config.each { |key, value| subject.config[key] = value }
24
24
  subject.name_args = [ipblock.id]
25
25
 
26
+ ip_consumers = (ipblock.properties.ip_consumers.nil? ? [] : ipblock.properties.ip_consumers.map { |el| el.to_hash })
26
27
  expect(subject).to receive(:puts).with("ID: #{ipblock.id}")
27
28
  expect(subject).to receive(:puts).with("Name: #{ipblock.properties.name}")
28
29
  expect(subject).to receive(:puts).with("IP Addresses: #{ipblock.properties.ips.to_s}")
29
30
  expect(subject).to receive(:puts).with("Location: #{ipblock.properties.location}")
31
+ expect(subject).to receive(:puts).with("IP Consumers: #{ip_consumers}")
30
32
  expect(subject.ui).to receive(:warn).with("Released IP block #{ipblock.id}. Request ID: ")
31
33
 
32
34
  expect(subject.api_client).not_to receive(:wait_for)
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_ipblock_get'
3
+
4
+ Chef::Knife::IonoscloudIpblockGet.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudIpblockGet do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudIpblockGet.new }
9
+
10
+ allow(subject).to receive(:puts)
11
+ allow(subject).to receive(:print)
12
+ end
13
+
14
+ describe '#run' do
15
+ it 'should call IPBlocksApi.ipblocks_find_by_id' do
16
+ ipblock = ipblock_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ ipblock_id: ipblock.id,
21
+ }
22
+
23
+ subject_config.each { |key, value| subject.config[key] = value }
24
+
25
+ ip_consumers = (ipblock.properties.ip_consumers.nil? ? [] : ipblock.properties.ip_consumers.map { |el| el.to_hash })
26
+ expect(subject).to receive(:puts).with("ID: #{ipblock.id}")
27
+ expect(subject).to receive(:puts).with("Name: #{ipblock.properties.name}")
28
+ expect(subject).to receive(:puts).with("IP Addresses: #{ipblock.properties.ips.to_s}")
29
+ expect(subject).to receive(:puts).with("Location: #{ipblock.properties.location}")
30
+ expect(subject).to receive(:puts).with("IP Consumers: #{ip_consumers}")
31
+
32
+ mock_call_api(
33
+ subject,
34
+ [
35
+ {
36
+ method: 'GET',
37
+ path: "/ipblocks/#{ipblock.id}",
38
+ operation: :'IPBlocksApi.ipblocks_find_by_id',
39
+ return_type: 'IpBlock',
40
+ result: ipblock,
41
+ },
42
+ ],
43
+ )
44
+
45
+ expect { subject.run }.not_to raise_error(Exception)
46
+ end
47
+
48
+ it 'should not make any call if any required option is missing' do
49
+ required_options = subject.instance_variable_get(:@required_options)
50
+
51
+ arrays_without_one_element(required_options).each do |test_case|
52
+
53
+ test_case[:array].each { |value| subject.config[value] = 'test' }
54
+
55
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
56
+ expect(subject.api_client).not_to receive(:call_api)
57
+
58
+ expect { subject.run }.to raise_error(SystemExit) do |error|
59
+ expect(error.status).to eq(1)
60
+ end
61
+
62
+ required_options.each { |value| subject.config[value] = nil }
63
+ end
64
+ end
65
+ end
66
+ end
@@ -34,7 +34,7 @@ describe Chef::Knife::IonoscloudIpblockList do
34
34
  ipblock_list << ipblock.properties.name
35
35
  ipblock_list << ipblock.properties.location
36
36
  ipblock_list << ipblock.properties.ips.join(', ')
37
- ipblock_list << ipblock.properties.ip_consumers.nil? ? 0 : ipblock.properties.ip_consumers.length
37
+ ipblock_list << (ipblock.properties.ip_consumers.nil? ? 0 : ipblock.properties.ip_consumers.length)
38
38
  end
39
39
 
40
40
  expect(subject.ui).to receive(:list).with(ipblock_list, :uneven_columns_across, 5)
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_ipblock_update'
3
+
4
+ Chef::Knife::IonoscloudIpblockUpdate.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudIpblockUpdate do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudIpblockUpdate.new }
9
+
10
+ allow(subject).to receive(:puts)
11
+ allow(subject).to receive(:print)
12
+ end
13
+
14
+ describe '#run' do
15
+ it 'should call DataCenterApi.datacenters_patch' do
16
+ ipblock = ipblock_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ ipblock_id: ipblock.id,
21
+ name: ipblock.properties.name + '_edited',
22
+ yes: true,
23
+ }
24
+
25
+ subject_config.each { |key, value| subject.config[key] = value }
26
+
27
+ ip_consumers = (ipblock.properties.ip_consumers.nil? ? [] : ipblock.properties.ip_consumers.map { |el| el.to_hash })
28
+ expect(subject).to receive(:puts).with("ID: #{ipblock.id}")
29
+ expect(subject).to receive(:puts).with("Name: #{subject_config[:name]}")
30
+ expect(subject).to receive(:puts).with("IP Addresses: #{ipblock.properties.ips.to_s}")
31
+ expect(subject).to receive(:puts).with("Location: #{ipblock.properties.location}")
32
+ expect(subject).to receive(:puts).with("IP Consumers: #{ip_consumers}")
33
+
34
+ ipblock.properties.name = subject_config[:name]
35
+
36
+ mock_wait_for(subject)
37
+ mock_call_api(
38
+ subject,
39
+ [
40
+ {
41
+ method: 'PATCH',
42
+ path: "/ipblocks/#{ipblock.id}",
43
+ operation: :'IPBlocksApi.ipblocks_patch',
44
+ return_type: 'IpBlock',
45
+ body: { name: subject_config[:name] },
46
+ result: ipblock,
47
+ },
48
+ {
49
+ method: 'GET',
50
+ path: "/ipblocks/#{ipblock.id}",
51
+ operation: :'IPBlocksApi.ipblocks_find_by_id',
52
+ return_type: 'IpBlock',
53
+ result: ipblock,
54
+ },
55
+ ],
56
+ )
57
+
58
+ expect { subject.run }.not_to raise_error(Exception)
59
+ end
60
+
61
+ it 'should not make any call if any required option is missing' do
62
+ required_options = subject.instance_variable_get(:@required_options)
63
+
64
+ arrays_without_one_element(required_options).each do |test_case|
65
+
66
+ test_case[:array].each { |value| subject.config[value] = 'test' }
67
+
68
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
69
+ expect(subject.api_client).not_to receive(:call_api)
70
+
71
+ expect { subject.run }.to raise_error(SystemExit) do |error|
72
+ expect(error.status).to eq(1)
73
+ end
74
+
75
+ required_options.each { |value| subject.config[value] = nil }
76
+ end
77
+ end
78
+ end
79
+ end
@@ -20,7 +20,7 @@ describe Chef::Knife::IonoscloudIpfailoverAdd do
20
20
  datacenter_id: 'datacenter_id',
21
21
  lan_id: lan.id,
22
22
  nic_id: 'nic_id',
23
- ip: '1.1.1.1',
23
+ ip: '127.1.1.1',
24
24
  yes: true,
25
25
  }
26
26
 
@@ -29,6 +29,7 @@ describe Chef::Knife::IonoscloudIpfailoverAdd do
29
29
  expect(subject).to receive(:puts).with("ID: #{lan.id}")
30
30
  expect(subject).to receive(:puts).with("Name: #{lan.properties.name}")
31
31
  expect(subject).to receive(:puts).with("Public: #{lan.properties.public.to_s}")
32
+ expect(subject).to receive(:puts).with("PCC: #{lan.properties.pcc}")
32
33
  expect(subject).to receive(:puts).with("IP Failover: #{[{ ip: subject_config[:ip], nicUuid: subject_config[:nic_id] }]}")
33
34
 
34
35
  mock_wait_for(subject)
@@ -13,7 +13,7 @@ describe Chef::Knife::IonoscloudIpfailoverRemove do
13
13
 
14
14
  describe '#run' do
15
15
  it 'should call Lan.datacenters_lans_patch when the ip failvoer rule exists' do
16
- lan = lan_mock({ ip_failover: [ Ionoscloud::IPFailover.new(ip: '1.1.1.2', nic_uuid: 'nic_id2')] })
16
+ lan = lan_mock({ ip_failover: [ Ionoscloud::IPFailover.new(ip: '127.1.1.2', nic_uuid: 'nic_id2')] })
17
17
  subject_config = {
18
18
  ionoscloud_username: 'email',
19
19
  ionoscloud_password: 'password',
@@ -29,6 +29,7 @@ describe Chef::Knife::IonoscloudIpfailoverRemove do
29
29
  expect(subject).to receive(:puts).with("ID: #{lan.id}")
30
30
  expect(subject).to receive(:puts).with("Name: #{lan.properties.name}")
31
31
  expect(subject).to receive(:puts).with("Public: #{lan.properties.public.to_s}")
32
+ expect(subject).to receive(:puts).with("PCC: #{lan.properties.pcc}")
32
33
  expect(subject).to receive(:puts).with("IP Failover: #{[]}")
33
34
 
34
35
  lan_copy = Marshal.load(Marshal.dump(lan))
@@ -66,14 +67,14 @@ describe Chef::Knife::IonoscloudIpfailoverRemove do
66
67
  end
67
68
 
68
69
  it 'should not call Lan.datacenters_lans_patch when the ip failvoer rule does not exist' do
69
- lan = lan_mock({ ip_failover: [ Ionoscloud::IPFailover.new(ip: '1.1.1.2', nic_uuid: 'nic_id2')] })
70
+ lan = lan_mock({ ip_failover: [ Ionoscloud::IPFailover.new(ip: '127.1.1.2', nic_uuid: 'nic_id2')] })
70
71
  subject_config = {
71
72
  ionoscloud_username: 'email',
72
73
  ionoscloud_password: 'password',
73
74
  datacenter_id: 'datacenter_id',
74
75
  lan_id: lan.id,
75
76
  nic_id: 'nic_id',
76
- ip: '1.1.1.1',
77
+ ip: '127.1.1.1',
77
78
  yes: true,
78
79
  }
79
80
 
@@ -21,17 +21,25 @@ describe Chef::Knife::IonoscloudK8sCreate do
21
21
  version: cluster.properties.k8s_version,
22
22
  maintenance_day: cluster.properties.maintenance_window.day_of_the_week,
23
23
  maintenance_time: cluster.properties.maintenance_window.time,
24
+ s3_buckets: cluster.properties.s3_buckets.map { |el| el.name }.join(','),
25
+ api_subnet_allow_list: cluster.properties.api_subnet_allow_list.join(','),
24
26
  }
25
27
 
26
28
  subject_config.each { |key, value| subject.config[key] = value }
27
29
 
28
30
  maintenance_window = "#{cluster.properties.maintenance_window.day_of_the_week}, #{cluster.properties.maintenance_window.time}"
31
+ s3_buckets = (cluster.properties.s3_buckets.nil? ? [] : cluster.properties.s3_buckets.map { |el| el.name })
29
32
 
30
33
  expect(subject).to receive(:puts).with("ID: #{cluster.id}")
31
34
  expect(subject).to receive(:puts).with("Name: #{cluster.properties.name}")
35
+ expect(subject).to receive(:puts).with("Public: #{cluster.properties.public}")
32
36
  expect(subject).to receive(:puts).with("k8s Version: #{cluster.properties.k8s_version}")
33
37
  expect(subject).to receive(:puts).with("Maintenance Window: #{maintenance_window}")
34
38
  expect(subject).to receive(:puts).with("State: #{cluster.metadata.state}")
39
+ expect(subject).to receive(:puts).with("Api Subnet Allow List: #{cluster.properties.api_subnet_allow_list}")
40
+ expect(subject).to receive(:puts).with("S3 Buckets: #{s3_buckets}")
41
+ expect(subject).to receive(:puts).with("Available Upgrade Versions: #{cluster.properties.available_upgrade_versions}")
42
+ expect(subject).to receive(:puts).with("Viable NodePool Versions: #{cluster.properties.viable_node_pool_versions}")
35
43
 
36
44
  expected_body = cluster.properties.to_hash
37
45
  expected_body.delete(:viableNodePoolVersions)
@@ -26,12 +26,18 @@ describe Chef::Knife::IonoscloudK8sDelete do
26
26
  subject.name_args = [k8s_cluster.id]
27
27
 
28
28
  maintenance_window = "#{k8s_cluster.properties.maintenance_window.day_of_the_week}, #{k8s_cluster.properties.maintenance_window.time}"
29
+ s3_buckets = (k8s_cluster.properties.s3_buckets.nil? ? [] : k8s_cluster.properties.s3_buckets.map { |el| el.name })
29
30
 
30
31
  expect(subject).to receive(:puts).with("ID: #{k8s_cluster.id}")
31
32
  expect(subject).to receive(:puts).with("Name: #{k8s_cluster.properties.name}")
32
- expect(subject).to receive(:puts).with("Version: #{k8s_cluster.properties.k8s_version}")
33
+ expect(subject).to receive(:puts).with("Public: #{k8s_cluster.properties.public}")
34
+ expect(subject).to receive(:puts).with("k8s Version: #{k8s_cluster.properties.k8s_version}")
33
35
  expect(subject).to receive(:puts).with("Maintenance Window: #{maintenance_window}")
34
36
  expect(subject).to receive(:puts).with("State: #{k8s_cluster.metadata.state}")
37
+ expect(subject).to receive(:puts).with("Api Subnet Allow List: #{k8s_cluster.properties.api_subnet_allow_list}")
38
+ expect(subject).to receive(:puts).with("S3 Buckets: #{s3_buckets}")
39
+ expect(subject).to receive(:puts).with("Available Upgrade Versions: #{k8s_cluster.properties.available_upgrade_versions}")
40
+ expect(subject).to receive(:puts).with("Viable NodePool Versions: #{k8s_cluster.properties.viable_node_pool_versions}")
35
41
  expect(subject.ui).to receive(:warn).with("Deleted K8s Cluster #{k8s_cluster.id}. Request ID: ")
36
42
 
37
43
  expect(subject).not_to receive(:wait_for)
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_k8s_get'
3
+
4
+ Chef::Knife::IonoscloudK8sGet.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudK8sGet do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudK8sGet.new }
9
+
10
+ allow(subject).to receive(:puts)
11
+ allow(subject).to receive(:print)
12
+ end
13
+
14
+ describe '#run' do
15
+ it 'should call KubernetesApi.k8s_find_by_cluster_id' do
16
+ cluster = k8s_cluster_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ cluster_id: cluster.id,
21
+ }
22
+
23
+ subject_config.each { |key, value| subject.config[key] = value }
24
+
25
+ maintenance_window = "#{cluster.properties.maintenance_window.day_of_the_week}, #{cluster.properties.maintenance_window.time}"
26
+ s3_buckets = (cluster.properties.s3_buckets.nil? ? [] : cluster.properties.s3_buckets.map { |el| el.name })
27
+
28
+ expect(subject).to receive(:puts).with("ID: #{cluster.id}")
29
+ expect(subject).to receive(:puts).with("Name: #{cluster.properties.name}")
30
+ expect(subject).to receive(:puts).with("Public: #{cluster.properties.public}")
31
+ expect(subject).to receive(:puts).with("k8s Version: #{cluster.properties.k8s_version}")
32
+ expect(subject).to receive(:puts).with("Maintenance Window: #{maintenance_window}")
33
+ expect(subject).to receive(:puts).with("State: #{cluster.metadata.state}")
34
+ expect(subject).to receive(:puts).with("Api Subnet Allow List: #{cluster.properties.api_subnet_allow_list}")
35
+ expect(subject).to receive(:puts).with("S3 Buckets: #{s3_buckets}")
36
+ expect(subject).to receive(:puts).with("Available Upgrade Versions: #{cluster.properties.available_upgrade_versions}")
37
+ expect(subject).to receive(:puts).with("Viable NodePool Versions: #{cluster.properties.viable_node_pool_versions}")
38
+
39
+ mock_call_api(
40
+ subject,
41
+ [
42
+ {
43
+ method: 'GET',
44
+ path: "/k8s/#{cluster.id}",
45
+ operation: :'KubernetesApi.k8s_find_by_cluster_id',
46
+ return_type: 'KubernetesCluster',
47
+ result: cluster,
48
+ },
49
+ ],
50
+ )
51
+
52
+ expect { subject.run }.not_to raise_error(Exception)
53
+ end
54
+
55
+ it 'should not make any call if any required option is missing' do
56
+ required_options = subject.instance_variable_get(:@required_options)
57
+
58
+ arrays_without_one_element(required_options).each do |test_case|
59
+
60
+ test_case[:array].each { |value| subject.config[value] = 'test' }
61
+
62
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
63
+ expect(subject.api_client).not_to receive(:call_api)
64
+
65
+ expect { subject.run }.to raise_error(SystemExit) do |error|
66
+ expect(error.status).to eq(1)
67
+ end
68
+
69
+ required_options.each { |value| subject.config[value] = nil }
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,115 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_k8s_update'
3
+
4
+ Chef::Knife::IonoscloudK8sUpdate.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudK8sUpdate do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudK8sUpdate.new }
9
+
10
+ allow(subject).to receive(:puts)
11
+ allow(subject).to receive(:print)
12
+ end
13
+
14
+ describe '#run' do
15
+ it 'should call NicApi.datacenters_servers_nics_clusterrules_patch' do
16
+ cluster = k8s_cluster_mock
17
+
18
+ subject_config = {
19
+ ionoscloud_username: 'email',
20
+ ionoscloud_password: 'password',
21
+ cluster_id: cluster.id,
22
+ name: cluster.properties.name + '_edited',
23
+ version: '19.9.9',
24
+ maintenance_day: 'Monday',
25
+ maintenance_time: '13:03:19Z',
26
+ api_subnet_allow_list: (cluster.properties.api_subnet_allow_list + ['1.1.1.1']).join(','),
27
+ s3_buckets: (cluster.properties.s3_buckets.map { |el| el.name } + ['new_bucket']).join(','),
28
+ yes: true,
29
+ }
30
+
31
+ subject_config.each { |key, value| subject.config[key] = value }
32
+
33
+ maintenance_window = "#{subject_config[:maintenance_day]}, #{subject_config[:maintenance_time]}"
34
+ s3_buckets = (cluster.properties.s3_buckets.map { |el| el.name } + ['new_bucket'])
35
+
36
+ expect(subject).to receive(:puts).with("ID: #{cluster.id}")
37
+ expect(subject).to receive(:puts).with("Name: #{subject_config[:name]}")
38
+ expect(subject).to receive(:puts).with("Public: #{cluster.properties.public}")
39
+ expect(subject).to receive(:puts).with("k8s Version: #{subject_config[:version]}")
40
+ expect(subject).to receive(:puts).with("Maintenance Window: #{maintenance_window}")
41
+ expect(subject).to receive(:puts).with("State: #{cluster.metadata.state}")
42
+ expect(subject).to receive(:puts).with("Api Subnet Allow List: #{cluster.properties.api_subnet_allow_list + ['1.1.1.1']}")
43
+ expect(subject).to receive(:puts).with("S3 Buckets: #{s3_buckets}")
44
+ expect(subject).to receive(:puts).with("Available Upgrade Versions: #{cluster.properties.available_upgrade_versions}")
45
+ expect(subject).to receive(:puts).with("Viable NodePool Versions: #{cluster.properties.viable_node_pool_versions}")
46
+
47
+ cluster.properties.name = subject_config[:name]
48
+ cluster.properties.k8s_version = subject_config[:version]
49
+ cluster.properties.maintenance_window.day_of_the_week = subject_config[:maintenance_day]
50
+ cluster.properties.maintenance_window.time = subject_config[:maintenance_time]
51
+ cluster.properties.api_subnet_allow_list = subject_config[:api_subnet_allow_list].split(',')
52
+ cluster.properties.s3_buckets = subject_config[:s3_buckets].split(',').map { |el| Ionoscloud::S3Bucket.new(name: el) }
53
+
54
+ expected_body = {
55
+ name: subject_config[:name],
56
+ k8sVersion: subject_config[:version],
57
+ maintenanceWindow: {
58
+ dayOfTheWeek: subject_config[:maintenance_day],
59
+ time: subject_config[:maintenance_time],
60
+ },
61
+ apiSubnetAllowList: subject_config[:api_subnet_allow_list].split(','),
62
+ s3Buckets: subject_config[:s3_buckets].split(',').map { |el| { name: el } },
63
+ }
64
+
65
+ expect(subject.api_client).not_to receive(:wait_for)
66
+ mock_call_api(
67
+ subject,
68
+ [
69
+ {
70
+ method: 'GET',
71
+ path: "/k8s/#{cluster.id}",
72
+ operation: :'KubernetesApi.k8s_find_by_cluster_id',
73
+ return_type: 'KubernetesCluster',
74
+ result: cluster,
75
+ },
76
+ {
77
+ method: 'PUT',
78
+ path: "/k8s/#{cluster.id}",
79
+ operation: :'KubernetesApi.k8s_put',
80
+ return_type: 'KubernetesCluster',
81
+ body: { properties: expected_body },
82
+ result: cluster,
83
+ },
84
+ {
85
+ method: 'GET',
86
+ path: "/k8s/#{cluster.id}",
87
+ operation: :'KubernetesApi.k8s_find_by_cluster_id',
88
+ return_type: 'KubernetesCluster',
89
+ result: cluster,
90
+ },
91
+ ],
92
+ )
93
+
94
+ expect { subject.run }.not_to raise_error(Exception)
95
+ end
96
+
97
+ it 'should not make any call if any required option is missing' do
98
+ required_options = subject.instance_variable_get(:@required_options)
99
+
100
+ arrays_without_one_element(required_options).each do |test_case|
101
+
102
+ test_case[:array].each { |value| subject.config[value] = 'test' }
103
+
104
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
105
+ expect(subject.api_client).not_to receive(:call_api)
106
+
107
+ expect { subject.run }.to raise_error(SystemExit) do |error|
108
+ expect(error.status).to eq(1)
109
+ end
110
+
111
+ required_options.each { |value| subject.config[value] = nil }
112
+ end
113
+ end
114
+ end
115
+ end
@@ -29,6 +29,7 @@ describe Chef::Knife::IonoscloudLanCreate do
29
29
  expect(subject).to receive(:puts).with("Name: #{lan.properties.name}")
30
30
  expect(subject).to receive(:puts).with("Public: #{lan.properties.public.to_s}")
31
31
  expect(subject).to receive(:puts).with("PCC: #{lan.properties.pcc}")
32
+ expect(subject).to receive(:puts).with("IP Failover: #{[]}")
32
33
 
33
34
  expected_body = lan.properties.to_hash
34
35
  expected_body.delete(:ipFailover)
@@ -27,6 +27,8 @@ describe Chef::Knife::IonoscloudLanDelete do
27
27
  expect(subject).to receive(:puts).with("ID: #{lan.id}")
28
28
  expect(subject).to receive(:puts).with("Name: #{lan.properties.name}")
29
29
  expect(subject).to receive(:puts).with("Public: #{lan.properties.public.to_s}")
30
+ expect(subject).to receive(:puts).with("PCC: #{lan.properties.pcc}")
31
+ expect(subject).to receive(:puts).with("IP Failover: #{[]}")
30
32
  expect(subject.ui).to receive(:warn).with("Deleted Lan #{lan.id}. Request ID: ")
31
33
 
32
34
  expect(subject.api_client).not_to receive(:wait_for)