knife-ionoscloud 6.0.0.beta.1 → 6.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chef/knife/ionoscloud_backupunit_create.rb +10 -14
  3. data/lib/chef/knife/ionoscloud_backupunit_delete.rb +1 -4
  4. data/lib/chef/knife/ionoscloud_backupunit_get.rb +33 -0
  5. data/lib/chef/knife/ionoscloud_backupunit_update.rb +62 -0
  6. data/lib/chef/knife/ionoscloud_base.rb +308 -0
  7. data/lib/chef/knife/ionoscloud_cube_server_create.rb +3 -7
  8. data/lib/chef/knife/ionoscloud_datacenter_create.rb +10 -13
  9. data/lib/chef/knife/ionoscloud_datacenter_delete.rb +1 -6
  10. data/lib/chef/knife/ionoscloud_datacenter_get.rb +33 -0
  11. data/lib/chef/knife/ionoscloud_datacenter_update.rb +67 -0
  12. data/lib/chef/knife/ionoscloud_firewall_create.rb +7 -19
  13. data/lib/chef/knife/ionoscloud_firewall_delete.rb +2 -11
  14. data/lib/chef/knife/ionoscloud_firewall_get.rb +52 -0
  15. data/lib/chef/knife/ionoscloud_firewall_update.rb +133 -0
  16. data/lib/chef/knife/ionoscloud_flowlog_create.rb +4 -10
  17. data/lib/chef/knife/ionoscloud_flowlog_delete.rb +8 -12
  18. data/lib/chef/knife/ionoscloud_flowlog_get.rb +84 -0
  19. data/lib/chef/knife/ionoscloud_flowlog_list.rb +2 -2
  20. data/lib/chef/knife/ionoscloud_flowlog_update.rb +127 -0
  21. data/lib/chef/knife/ionoscloud_group_create.rb +1 -16
  22. data/lib/chef/knife/ionoscloud_group_delete.rb +1 -18
  23. data/lib/chef/knife/ionoscloud_group_get.rb +1 -19
  24. data/lib/chef/knife/ionoscloud_group_update.rb +131 -0
  25. data/lib/chef/knife/ionoscloud_group_user_add.rb +1 -18
  26. data/lib/chef/knife/ionoscloud_group_user_remove.rb +1 -18
  27. data/lib/chef/knife/ionoscloud_ipblock_create.rb +10 -13
  28. data/lib/chef/knife/ionoscloud_ipblock_delete.rb +1 -4
  29. data/lib/chef/knife/ionoscloud_ipblock_get.rb +33 -0
  30. data/lib/chef/knife/ionoscloud_ipblock_update.rb +57 -0
  31. data/lib/chef/knife/ionoscloud_k8s_create.rb +27 -35
  32. data/lib/chef/knife/ionoscloud_k8s_delete.rb +1 -9
  33. data/lib/chef/knife/ionoscloud_k8s_get.rb +33 -0
  34. data/lib/chef/knife/ionoscloud_k8s_update.rb +99 -0
  35. data/lib/chef/knife/ionoscloud_lan_create.rb +5 -13
  36. data/lib/chef/knife/ionoscloud_lan_delete.rb +2 -3
  37. data/lib/chef/knife/ionoscloud_lan_get.rb +38 -0
  38. data/lib/chef/knife/ionoscloud_lan_list.rb +1 -0
  39. data/lib/chef/knife/ionoscloud_lan_update.rb +76 -0
  40. data/lib/chef/knife/ionoscloud_loadbalancer_create.rb +3 -13
  41. data/lib/chef/knife/ionoscloud_loadbalancer_delete.rb +1 -8
  42. data/lib/chef/knife/ionoscloud_loadbalancer_get.rb +2 -12
  43. data/lib/chef/knife/ionoscloud_loadbalancer_nic_add.rb +2 -14
  44. data/lib/chef/knife/ionoscloud_loadbalancer_nic_remove.rb +2 -15
  45. data/lib/chef/knife/ionoscloud_loadbalancer_update.rb +73 -0
  46. data/lib/chef/knife/ionoscloud_natgateway_create.rb +4 -14
  47. data/lib/chef/knife/ionoscloud_natgateway_delete.rb +2 -18
  48. data/lib/chef/knife/ionoscloud_natgateway_get.rb +42 -0
  49. data/lib/chef/knife/ionoscloud_natgateway_lan_add.rb +1 -8
  50. data/lib/chef/knife/ionoscloud_natgateway_lan_remove.rb +1 -8
  51. data/lib/chef/knife/ionoscloud_natgateway_list.rb +1 -0
  52. data/lib/chef/knife/ionoscloud_natgateway_rule_add.rb +4 -22
  53. data/lib/chef/knife/ionoscloud_natgateway_rule_list.rb +1 -0
  54. data/lib/chef/knife/ionoscloud_natgateway_rule_remove.rb +3 -21
  55. data/lib/chef/knife/ionoscloud_natgateway_rule_update.rb +116 -0
  56. data/lib/chef/knife/ionoscloud_natgateway_update.rb +84 -0
  57. data/lib/chef/knife/ionoscloud_networkloadbalancer_create.rb +4 -11
  58. data/lib/chef/knife/ionoscloud_networkloadbalancer_delete.rb +2 -22
  59. data/lib/chef/knife/ionoscloud_networkloadbalancer_get.rb +42 -0
  60. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_add.rb +25 -35
  61. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_list.rb +1 -0
  62. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_remove.rb +19 -30
  63. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_add.rb +4 -22
  64. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_list.rb +1 -0
  65. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove.rb +4 -22
  66. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_update.rb +148 -0
  67. data/lib/chef/knife/ionoscloud_networkloadbalancer_update.rb +98 -0
  68. data/lib/chef/knife/ionoscloud_nic_create.rb +6 -16
  69. data/lib/chef/knife/ionoscloud_nic_delete.rb +2 -8
  70. data/lib/chef/knife/ionoscloud_nic_get.rb +49 -0
  71. data/lib/chef/knife/ionoscloud_nic_update.rb +96 -0
  72. data/lib/chef/knife/ionoscloud_node_get.rb +49 -0
  73. data/lib/chef/knife/ionoscloud_nodepool_create.rb +22 -51
  74. data/lib/chef/knife/ionoscloud_nodepool_delete.rb +1 -32
  75. data/lib/chef/knife/ionoscloud_nodepool_get.rb +43 -0
  76. data/lib/chef/knife/ionoscloud_nodepool_lan_add.rb +1 -26
  77. data/lib/chef/knife/ionoscloud_nodepool_lan_remove.rb +1 -26
  78. data/lib/chef/knife/ionoscloud_nodepool_update.rb +124 -0
  79. data/lib/chef/knife/ionoscloud_pcc_create.rb +9 -15
  80. data/lib/chef/knife/ionoscloud_pcc_delete.rb +1 -9
  81. data/lib/chef/knife/ionoscloud_pcc_get.rb +33 -0
  82. data/lib/chef/knife/ionoscloud_pcc_update.rb +63 -0
  83. data/lib/chef/knife/ionoscloud_request_get.rb +40 -0
  84. data/lib/chef/knife/ionoscloud_s3key_create.rb +1 -5
  85. data/lib/chef/knife/ionoscloud_s3key_delete.rb +1 -4
  86. data/lib/chef/knife/ionoscloud_s3key_get.rb +38 -0
  87. data/lib/chef/knife/ionoscloud_server_create.rb +12 -24
  88. data/lib/chef/knife/ionoscloud_server_delete.rb +2 -8
  89. data/lib/chef/knife/ionoscloud_server_get.rb +43 -0
  90. data/lib/chef/knife/ionoscloud_server_update.rb +97 -0
  91. data/lib/chef/knife/ionoscloud_share_create.rb +7 -11
  92. data/lib/chef/knife/ionoscloud_share_delete.rb +2 -3
  93. data/lib/chef/knife/ionoscloud_share_get.rb +38 -0
  94. data/lib/chef/knife/ionoscloud_share_update.rb +70 -0
  95. data/lib/chef/knife/ionoscloud_snapshot_create.rb +1 -9
  96. data/lib/chef/knife/ionoscloud_snapshot_delete.rb +1 -6
  97. data/lib/chef/knife/ionoscloud_snapshot_get.rb +32 -0
  98. data/lib/chef/knife/ionoscloud_snapshot_restore.rb +1 -12
  99. data/lib/chef/knife/ionoscloud_snapshot_update.rb +126 -0
  100. data/lib/chef/knife/ionoscloud_user_create.rb +1 -8
  101. data/lib/chef/knife/ionoscloud_user_delete.rb +1 -6
  102. data/lib/chef/knife/ionoscloud_user_get.rb +32 -0
  103. data/lib/chef/knife/ionoscloud_user_update.rb +92 -0
  104. data/lib/chef/knife/ionoscloud_volume_create.rb +1 -12
  105. data/lib/chef/knife/ionoscloud_volume_delete.rb +2 -8
  106. data/lib/chef/knife/ionoscloud_volume_get.rb +36 -0
  107. data/lib/chef/knife/ionoscloud_volume_update.rb +106 -0
  108. data/lib/knife-ionoscloud/version.rb +1 -1
  109. data/spec/chef/knife/ionoscloud_backupunit_get_spec.rb +65 -0
  110. data/spec/chef/knife/ionoscloud_backupunit_update_spec.rb +78 -0
  111. data/spec/chef/knife/ionoscloud_datacenter_create_spec.rb +3 -0
  112. data/spec/chef/knife/ionoscloud_datacenter_delete_spec.rb +3 -0
  113. data/spec/chef/knife/ionoscloud_datacenter_get_spec.rb +69 -0
  114. data/spec/chef/knife/ionoscloud_datacenter_update_spec.rb +82 -0
  115. data/spec/chef/knife/ionoscloud_firewall_create_spec.rb +1 -1
  116. data/spec/chef/knife/ionoscloud_firewall_delete_spec.rb +1 -1
  117. data/spec/chef/knife/ionoscloud_firewall_get_spec.rb +77 -0
  118. data/spec/chef/knife/ionoscloud_firewall_update_spec.rb +117 -0
  119. data/spec/chef/knife/ionoscloud_flowlog_create_spec.rb +3 -3
  120. data/spec/chef/knife/ionoscloud_flowlog_delete_spec.rb +10 -10
  121. data/spec/chef/knife/ionoscloud_flowlog_get_spec.rb +171 -0
  122. data/spec/chef/knife/ionoscloud_flowlog_list_spec.rb +3 -3
  123. data/spec/chef/knife/ionoscloud_flowlog_update_spec.rb +244 -0
  124. data/spec/chef/knife/ionoscloud_group_create_spec.rb +3 -0
  125. data/spec/chef/knife/ionoscloud_group_update_spec.rb +121 -0
  126. data/spec/chef/knife/ionoscloud_group_user_add_spec.rb +6 -0
  127. data/spec/chef/knife/ionoscloud_group_user_remove_spec.rb +6 -0
  128. data/spec/chef/knife/ionoscloud_ipblock_get_spec.rb +66 -0
  129. data/spec/chef/knife/ionoscloud_ipblock_update_spec.rb +79 -0
  130. data/spec/chef/knife/ionoscloud_ipfailover_add_spec.rb +1 -1
  131. data/spec/chef/knife/ionoscloud_ipfailover_remove_spec.rb +3 -3
  132. data/spec/chef/knife/ionoscloud_k8s_create_spec.rb +7 -0
  133. data/spec/chef/knife/ionoscloud_k8s_delete_spec.rb +16 -11
  134. data/spec/chef/knife/ionoscloud_k8s_get_spec.rb +72 -0
  135. data/spec/chef/knife/ionoscloud_k8s_update_spec.rb +114 -0
  136. data/spec/chef/knife/ionoscloud_lan_create_spec.rb +1 -0
  137. data/spec/chef/knife/ionoscloud_lan_delete_spec.rb +2 -0
  138. data/spec/chef/knife/ionoscloud_lan_get_spec.rb +68 -0
  139. data/spec/chef/knife/ionoscloud_lan_update_spec.rb +87 -0
  140. data/spec/chef/knife/ionoscloud_loadbalancer_update_spec.rb +89 -0
  141. data/spec/chef/knife/ionoscloud_natgateway_create_spec.rb +15 -0
  142. data/spec/chef/knife/ionoscloud_natgateway_get_spec.rb +81 -0
  143. data/spec/chef/knife/ionoscloud_natgateway_lan_add_spec.rb +15 -0
  144. data/spec/chef/knife/ionoscloud_natgateway_lan_remove_spec.rb +15 -0
  145. data/spec/chef/knife/ionoscloud_natgateway_rule_add_spec.rb +1 -0
  146. data/spec/chef/knife/ionoscloud_natgateway_rule_remove_spec.rb +1 -0
  147. data/spec/chef/knife/ionoscloud_natgateway_rule_update_spec.rb +121 -0
  148. data/spec/chef/knife/ionoscloud_natgateway_update_spec.rb +121 -0
  149. data/spec/chef/knife/ionoscloud_networkloadbalancer_create_spec.rb +13 -0
  150. data/spec/chef/knife/ionoscloud_networkloadbalancer_delete_spec.rb +3 -2
  151. data/spec/chef/knife/ionoscloud_networkloadbalancer_get_spec.rb +82 -0
  152. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_add_spec.rb +4 -3
  153. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_remove_spec.rb +70 -44
  154. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_add_spec.rb +26 -22
  155. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove_spec.rb +79 -61
  156. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_update_spec.rb +163 -0
  157. data/spec/chef/knife/ionoscloud_networkloadbalancer_update_spec.rb +107 -0
  158. data/spec/chef/knife/ionoscloud_nic_get_spec.rb +72 -0
  159. data/spec/chef/knife/ionoscloud_nic_update_spec.rb +97 -0
  160. data/spec/chef/knife/ionoscloud_node_get_spec.rb +70 -0
  161. data/spec/chef/knife/ionoscloud_nodepool_create_spec.rb +8 -17
  162. data/spec/chef/knife/ionoscloud_nodepool_delete_spec.rb +14 -0
  163. data/spec/chef/knife/ionoscloud_nodepool_get_spec.rb +83 -0
  164. data/spec/chef/knife/ionoscloud_nodepool_lan_add_spec.rb +29 -33
  165. data/spec/chef/knife/ionoscloud_nodepool_lan_remove.rb +14 -17
  166. data/spec/chef/knife/ionoscloud_nodepool_update_spec.rb +134 -0
  167. data/spec/chef/knife/ionoscloud_pcc_create_spec.rb +5 -2
  168. data/spec/chef/knife/ionoscloud_pcc_delete_spec.rb +2 -2
  169. data/spec/chef/knife/ionoscloud_pcc_get_spec.rb +71 -0
  170. data/spec/chef/knife/ionoscloud_pcc_update_spec.rb +83 -0
  171. data/spec/chef/knife/ionoscloud_request_get_spec.rb +69 -0
  172. data/spec/chef/knife/ionoscloud_s3key_get_spec.rb +66 -0
  173. data/spec/chef/knife/ionoscloud_server_create_spec.rb +3 -0
  174. data/spec/chef/knife/ionoscloud_server_delete_spec.rb +3 -0
  175. data/spec/chef/knife/ionoscloud_server_get_spec.rb +74 -0
  176. data/spec/chef/knife/ionoscloud_server_update_spec.rb +105 -0
  177. data/spec/chef/knife/ionoscloud_share_get_spec.rb +66 -0
  178. data/spec/chef/knife/ionoscloud_share_update_spec.rb +91 -0
  179. data/spec/chef/knife/ionoscloud_snapshot_create_spec.rb +12 -0
  180. data/spec/chef/knife/ionoscloud_snapshot_delete_spec.rb +12 -0
  181. data/spec/chef/knife/ionoscloud_snapshot_get_spec.rb +79 -0
  182. data/spec/chef/knife/ionoscloud_snapshot_restore_spec.rb +9 -0
  183. data/spec/chef/knife/ionoscloud_snapshot_update_spec.rb +113 -0
  184. data/spec/chef/knife/ionoscloud_user_create_spec.rb +3 -1
  185. data/spec/chef/knife/ionoscloud_user_delete_spec.rb +4 -2
  186. data/spec/chef/knife/ionoscloud_user_get_spec.rb +70 -0
  187. data/spec/chef/knife/ionoscloud_user_update_spec.rb +110 -0
  188. data/spec/chef/knife/ionoscloud_volume_create_spec.rb +15 -5
  189. data/spec/chef/knife/ionoscloud_volume_delete_spec.rb +10 -0
  190. data/spec/chef/knife/ionoscloud_volume_get_spec.rb +81 -0
  191. data/spec/chef/knife/ionoscloud_volume_update_spec.rb +116 -0
  192. data/spec/spec_helper.rb +41 -23
  193. metadata +125 -2
@@ -0,0 +1,106 @@
1
+ require_relative 'ionoscloud_base'
2
+
3
+ class Chef
4
+ class Knife
5
+ class IonoscloudVolumeUpdate < Knife
6
+ include Knife::IonoscloudBase
7
+
8
+ banner 'knife ionoscloud volume update (options)'
9
+
10
+ option :datacenter_id,
11
+ short: '-D DATACENTER_ID',
12
+ long: '--datacenter-id DATACENTER_ID',
13
+ description: 'Name of the data center'
14
+
15
+ option :volume_id,
16
+ long: '--volume VOLUME_ID',
17
+ description: 'ID of the Volume.'
18
+
19
+ option :name,
20
+ short: '-n NAME',
21
+ long: '--name NAME',
22
+ description: 'Name of the volume'
23
+
24
+ option :size,
25
+ short: '-S SIZE',
26
+ long: '--size SIZE',
27
+ description: 'The size of the volume in GB'
28
+
29
+ option :bus,
30
+ short: '-b BUS',
31
+ long: '--bus BUS',
32
+ description: 'The bus type of the volume (VIRTIO or IDE)'
33
+
34
+ option :cpu_hot_plug,
35
+ long: '--cpu-hot-plug CPU_HOT_PLUG',
36
+ description: 'The licence type of the volume (LINUX, WINDOWS, UNKNOWN, OTHER)'
37
+
38
+ option :ram_hot_plug,
39
+ long: '--ram-hot-plug RAM_HOT_PLUG',
40
+ description: 'The licence type of the volume (LINUX, WINDOWS, UNKNOWN, OTHER)'
41
+
42
+ option :nic_hot_plug,
43
+ long: '--nic-hot-plug NIC_HOT_PLUG',
44
+ description: 'The licence type of the volume (LINUX, WINDOWS, UNKNOWN, OTHER)'
45
+
46
+ option :nic_hot_unplug,
47
+ long: '--nic-hot-unplug NIC_HOT_UNPLUG',
48
+ description: 'The licence type of the volume (LINUX, WINDOWS, UNKNOWN, OTHER)'
49
+
50
+ option :disc_virtio_hot_plug,
51
+ long: '--disc-virtio-hot_plug DISC_VIRTIO_HOT_PLUG',
52
+ description: 'The licence type of the volume (LINUX, WINDOWS, UNKNOWN, OTHER)'
53
+
54
+ option :disc_virtio_hot_unplug,
55
+ long: '--disc-virtio-hot_unplug DISC_VIRTIO_HOT_UNPLUG',
56
+ description: 'The licence type of the volume (LINUX, WINDOWS, UNKNOWN, OTHER)'
57
+
58
+ attr_reader :description, :required_options
59
+
60
+ def initialize(args = [])
61
+ super(args)
62
+ @description =
63
+ 'Updates information about a Ionoscloud Volume.'
64
+ @required_options = [:datacenter_id, :volume_id, :ionoscloud_username, :ionoscloud_password]
65
+ @updatable_fields = [
66
+ :name, :size, :bus, :cpu_hot_plug, :ram_hot_plug, :nic_hot_plug, :nic_hot_unplug, :disc_virtio_hot_plug, :disc_virtio_hot_unplug,
67
+ ]
68
+ end
69
+
70
+ def run
71
+ $stdout.sync = true
72
+ handle_extra_config
73
+ validate_required_params(@required_options, config)
74
+
75
+ volume_api = Ionoscloud::VolumesApi.new(api_client)
76
+
77
+ if @updatable_fields.map { |el| config[el] }.any?
78
+ print "#{ui.color('Updating Volume...', :magenta)}"
79
+
80
+ _, _, headers = volume_api.datacenters_volumes_patch_with_http_info(
81
+ config[:datacenter_id],
82
+ config[:volume_id],
83
+ Ionoscloud::VolumeProperties.new(
84
+ name: config[:name],
85
+ size: config[:size],
86
+ bus: config[:bus],
87
+ cpu_hot_plug: (config.key?(:cpu_hot_plug) ? config[:cpu_hot_plug].to_s.downcase == 'true' : nil),
88
+ ram_hot_plug: (config.key?(:ram_hot_plug) ? config[:ram_hot_plug].to_s.downcase == 'true' : nil),
89
+ nic_hot_plug: (config.key?(:nic_hot_plug) ? config[:nic_hot_plug].to_s.downcase == 'true' : nil),
90
+ nic_hot_unplug: (config.key?(:nic_hot_unplug) ? config[:nic_hot_unplug].to_s.downcase == 'true' : nil),
91
+ disc_virtio_hot_plug: (config.key?(:disc_virtio_hot_plug) ? config[:disc_virtio_hot_plug].to_s.downcase == 'true' : nil),
92
+ disc_virtio_hot_unplug: (config.key?(:disc_virtio_hot_unplug) ? config[:disc_virtio_hot_unplug].to_s.downcase == 'true' : nil),
93
+ ),
94
+ )
95
+
96
+ dot = ui.color('.', :magenta)
97
+ api_client.wait_for { print dot; is_done? get_request_id headers }
98
+ else
99
+ ui.warn("Nothing to update, please set one of the attributes #{@updatable_fields}.")
100
+ end
101
+
102
+ print_volume(volume_api.datacenters_volumes_find_by_id(config[:datacenter_id], config[:volume_id]))
103
+ end
104
+ end
105
+ end
106
+ end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Ionoscloud
3
- VERSION = '6.0.0.beta.1'
3
+ VERSION = '6.0.0.beta.2'
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_backupunit_get'
3
+
4
+ Chef::Knife::IonoscloudBackupunitGet.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudBackupunitGet do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudBackupunitGet.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 BackupUnitsApi.backupunits_find_by_id' do
16
+ backupunit = backupunit_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ backupunit_id: backupunit.id,
21
+ yes: true,
22
+ }
23
+
24
+ subject_config.each { |key, value| subject.config[key] = value }
25
+
26
+ expect(subject).to receive(:puts).with("ID: #{backupunit.id}")
27
+ expect(subject).to receive(:puts).with("Name: #{backupunit.properties.name}")
28
+ expect(subject).to receive(:puts).with("Email: #{backupunit.properties.email}")
29
+
30
+ expect(subject.api_client).not_to receive(:wait_for)
31
+ mock_call_api(
32
+ subject,
33
+ [
34
+ {
35
+ method: 'GET',
36
+ path: "/backupunits/#{backupunit.id}",
37
+ operation: :'BackupUnitsApi.backupunits_find_by_id',
38
+ return_type: 'BackupUnit',
39
+ result: backupunit,
40
+ },
41
+ ],
42
+ )
43
+
44
+ expect { subject.run }.not_to raise_error(Exception)
45
+ end
46
+
47
+ it 'should not make any call if any required option is missing' do
48
+ required_options = subject.instance_variable_get(:@required_options)
49
+
50
+ arrays_without_one_element(required_options).each do |test_case|
51
+
52
+ test_case[:array].each { |value| subject.config[value] = 'test' }
53
+
54
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
55
+ expect(subject.api_client).not_to receive(:call_api)
56
+
57
+ expect { subject.run }.to raise_error(SystemExit) do |error|
58
+ expect(error.status).to eq(1)
59
+ end
60
+
61
+ required_options.each { |value| subject.config[value] = nil }
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_backupunit_update'
3
+
4
+ Chef::Knife::IonoscloudBackupunitUpdate.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudBackupunitUpdate do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudBackupunitUpdate.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 BackupUnitsApi.backupunits_patch' do
16
+ backupunit = backupunit_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ backupunit_id: backupunit.id,
21
+ email: 'edited' + backupunit.properties.email,
22
+ password: 'password_edited',
23
+ yes: true,
24
+ }
25
+
26
+ subject_config.each { |key, value| subject.config[key] = value }
27
+
28
+
29
+ expect(subject).to receive(:puts).with("ID: #{backupunit.id}")
30
+ expect(subject).to receive(:puts).with("Name: #{backupunit.properties.name}")
31
+ expect(subject).to receive(:puts).with("Email: #{subject_config[:email]}")
32
+
33
+ backupunit.properties.email = subject_config[:email]
34
+
35
+ mock_wait_for(subject)
36
+ mock_call_api(
37
+ subject,
38
+ [
39
+ {
40
+ method: 'PATCH',
41
+ path: "/backupunits/#{backupunit.id}",
42
+ operation: :'BackupUnitsApi.backupunits_patch',
43
+ return_type: 'BackupUnit',
44
+ body: { email: subject_config[:email], password: subject_config[:password] },
45
+ result: backupunit,
46
+ },
47
+ {
48
+ method: 'GET',
49
+ path: "/backupunits/#{backupunit.id}",
50
+ operation: :'BackupUnitsApi.backupunits_find_by_id',
51
+ return_type: 'BackupUnit',
52
+ result: backupunit,
53
+ },
54
+ ],
55
+ )
56
+
57
+ expect { subject.run }.not_to raise_error(Exception)
58
+ end
59
+
60
+ it 'should not make any call if any required option is missing' do
61
+ required_options = subject.instance_variable_get(:@required_options)
62
+
63
+ arrays_without_one_element(required_options).each do |test_case|
64
+
65
+ test_case[:array].each { |value| subject.config[value] = 'test' }
66
+
67
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
68
+ expect(subject.api_client).not_to receive(:call_api)
69
+
70
+ expect { subject.run }.to raise_error(SystemExit) do |error|
71
+ expect(error.status).to eq(1)
72
+ end
73
+
74
+ required_options.each { |value| subject.config[value] = nil }
75
+ end
76
+ end
77
+ end
78
+ end
@@ -29,6 +29,9 @@ describe Chef::Knife::IonoscloudDatacenterCreate do
29
29
  expect(subject).to receive(:puts).with("Name: #{datacenter.properties.name}")
30
30
  expect(subject).to receive(:puts).with("Description: #{datacenter.properties.description}")
31
31
  expect(subject).to receive(:puts).with("Location: #{datacenter.properties.location}")
32
+ expect(subject).to receive(:puts).with("Version: #{datacenter.properties.version}")
33
+ expect(subject).to receive(:puts).with("Features: #{datacenter.properties.features}")
34
+ expect(subject).to receive(:puts).with("Sec Auth Protection: #{datacenter.properties.sec_auth_protection}")
32
35
 
33
36
  expected_body = datacenter.properties.to_hash
34
37
  expected_body.delete(:version)
@@ -27,6 +27,9 @@ describe Chef::Knife::IonoscloudDatacenterDelete do
27
27
  expect(subject).to receive(:puts).with("Name: #{datacenter.properties.name}")
28
28
  expect(subject).to receive(:puts).with("Description: #{datacenter.properties.description}")
29
29
  expect(subject).to receive(:puts).with("Location: #{datacenter.properties.location}")
30
+ expect(subject).to receive(:puts).with("Version: #{datacenter.properties.version}")
31
+ expect(subject).to receive(:puts).with("Features: #{datacenter.properties.features}")
32
+ expect(subject).to receive(:puts).with("Sec Auth Protection: #{datacenter.properties.sec_auth_protection}")
30
33
  expect(subject.ui).to receive(:warn).with("Deleted Data center #{datacenter.id}. Request ID: ")
31
34
 
32
35
  expect(subject.api_client).not_to receive(:wait_for)
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_datacenter_get'
3
+
4
+ Chef::Knife::IonoscloudDatacenterGet.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudDatacenterGet do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudDatacenterGet.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 DataCentersApi.datacenters_find_by_id' do
16
+ datacenter = datacenter_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ datacenter_id: datacenter.id,
21
+ yes: true,
22
+ }
23
+
24
+ subject_config.each { |key, value| subject.config[key] = value }
25
+
26
+ expect(subject).to receive(:puts).with("ID: #{datacenter.id}")
27
+ expect(subject).to receive(:puts).with("Name: #{datacenter.properties.name}")
28
+ expect(subject).to receive(:puts).with("Description: #{datacenter.properties.description}")
29
+ expect(subject).to receive(:puts).with("Location: #{datacenter.properties.location}")
30
+ expect(subject).to receive(:puts).with("Version: #{datacenter.properties.version}")
31
+ expect(subject).to receive(:puts).with("Features: #{datacenter.properties.features}")
32
+ expect(subject).to receive(:puts).with("Sec Auth Protection: #{datacenter.properties.sec_auth_protection}")
33
+
34
+ expect(subject.api_client).not_to receive(:wait_for)
35
+ mock_call_api(
36
+ subject,
37
+ [
38
+ {
39
+ method: 'GET',
40
+ path: "/datacenters/#{datacenter.id}",
41
+ operation: :'DataCentersApi.datacenters_find_by_id',
42
+ return_type: 'Datacenter',
43
+ result: datacenter,
44
+ },
45
+ ],
46
+ )
47
+
48
+ expect { subject.run }.not_to raise_error(Exception)
49
+ end
50
+
51
+ it 'should not make any call if any required option is missing' do
52
+ required_options = subject.instance_variable_get(:@required_options)
53
+
54
+ arrays_without_one_element(required_options).each do |test_case|
55
+
56
+ test_case[:array].each { |value| subject.config[value] = 'test' }
57
+
58
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
59
+ expect(subject.api_client).not_to receive(:call_api)
60
+
61
+ expect { subject.run }.to raise_error(SystemExit) do |error|
62
+ expect(error.status).to eq(1)
63
+ end
64
+
65
+ required_options.each { |value| subject.config[value] = nil }
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_datacenter_update'
3
+
4
+ Chef::Knife::IonoscloudDatacenterUpdate.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudDatacenterUpdate do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudDatacenterUpdate.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 DataCentersApi.datacenters_patch' do
16
+ datacenter = datacenter_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ datacenter_id: datacenter.id,
21
+ name: datacenter.properties.name + '_edited',
22
+ description: datacenter.properties.description + '_edited',
23
+ yes: true,
24
+ }
25
+
26
+ subject_config.each { |key, value| subject.config[key] = value }
27
+
28
+ expect(subject).to receive(:puts).with("ID: #{datacenter.id}")
29
+ expect(subject).to receive(:puts).with("Name: #{subject_config[:name]}")
30
+ expect(subject).to receive(:puts).with("Description: #{subject_config[:description]}")
31
+ expect(subject).to receive(:puts).with("Location: #{datacenter.properties.location}")
32
+ expect(subject).to receive(:puts).with("Version: #{datacenter.properties.version}")
33
+ expect(subject).to receive(:puts).with("Features: #{datacenter.properties.features}")
34
+ expect(subject).to receive(:puts).with("Sec Auth Protection: #{datacenter.properties.sec_auth_protection}")
35
+
36
+ datacenter.properties.name = subject_config[:name]
37
+ datacenter.properties.description = subject_config[:description]
38
+
39
+ mock_wait_for(subject)
40
+ mock_call_api(
41
+ subject,
42
+ [
43
+ {
44
+ method: 'PATCH',
45
+ path: "/datacenters/#{datacenter.id}",
46
+ operation: :'DataCentersApi.datacenters_patch',
47
+ return_type: 'Datacenter',
48
+ body: { name: subject_config[:name], description: subject_config[:description] },
49
+ result: datacenter,
50
+ },
51
+ {
52
+ method: 'GET',
53
+ path: "/datacenters/#{datacenter.id}",
54
+ operation: :'DataCentersApi.datacenters_find_by_id',
55
+ return_type: 'Datacenter',
56
+ result: datacenter,
57
+ },
58
+ ],
59
+ )
60
+
61
+ expect { subject.run }.not_to raise_error(Exception)
62
+ end
63
+
64
+ it 'should not make any call if any required option is missing' do
65
+ required_options = subject.instance_variable_get(:@required_options)
66
+
67
+ arrays_without_one_element(required_options).each do |test_case|
68
+
69
+ test_case[:array].each { |value| subject.config[value] = 'test' }
70
+
71
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
72
+ expect(subject.api_client).not_to receive(:call_api)
73
+
74
+ expect { subject.run }.to raise_error(SystemExit) do |error|
75
+ expect(error.status).to eq(1)
76
+ end
77
+
78
+ required_options.each { |value| subject.config[value] = nil }
79
+ end
80
+ end
81
+ end
82
+ end
@@ -36,6 +36,7 @@ describe Chef::Knife::IonoscloudFirewallCreate do
36
36
 
37
37
  expect(subject).to receive(:puts).with("ID: #{firewall.id}")
38
38
  expect(subject).to receive(:puts).with("Name: #{firewall.properties.name}")
39
+ expect(subject).to receive(:puts).with("Type: #{firewall.properties.type}")
39
40
  expect(subject).to receive(:puts).with("Protocol: #{firewall.properties.protocol}")
40
41
  expect(subject).to receive(:puts).with("Source MAC: #{firewall.properties.source_mac}")
41
42
  expect(subject).to receive(:puts).with("Source IP: #{firewall.properties.source_ip}")
@@ -44,7 +45,6 @@ describe Chef::Knife::IonoscloudFirewallCreate do
44
45
  expect(subject).to receive(:puts).with("Port Range End: #{firewall.properties.port_range_end}")
45
46
  expect(subject).to receive(:puts).with("ICMP Type: #{firewall.properties.icmp_type}")
46
47
  expect(subject).to receive(:puts).with("ICMP Code: #{firewall.properties.icmp_code}")
47
- expect(subject).to receive(:puts).with("Type: #{firewall.properties.type}")
48
48
 
49
49
  mock_wait_for(subject)
50
50
  mock_call_api(
@@ -28,6 +28,7 @@ describe Chef::Knife::IonoscloudFirewallDelete do
28
28
 
29
29
  expect(subject).to receive(:puts).with("ID: #{firewall.id}")
30
30
  expect(subject).to receive(:puts).with("Name: #{firewall.properties.name}")
31
+ expect(subject).to receive(:puts).with("Type: #{firewall.properties.type}")
31
32
  expect(subject).to receive(:puts).with("Protocol: #{firewall.properties.protocol}")
32
33
  expect(subject).to receive(:puts).with("Source MAC: #{firewall.properties.source_mac}")
33
34
  expect(subject).to receive(:puts).with("Source IP: #{firewall.properties.source_ip}")
@@ -36,7 +37,6 @@ describe Chef::Knife::IonoscloudFirewallDelete do
36
37
  expect(subject).to receive(:puts).with("Port Range End: #{firewall.properties.port_range_end}")
37
38
  expect(subject).to receive(:puts).with("ICMP Type: #{firewall.properties.icmp_type}")
38
39
  expect(subject).to receive(:puts).with("ICMP Code: #{firewall.properties.icmp_code}")
39
- expect(subject).to receive(:puts).with("Type: #{firewall.properties.type}")
40
40
  expect(subject.ui).to receive(:warn).with("Deleted Firewall rule #{firewall.id}. Request ID: ")
41
41
 
42
42
  expect(subject.api_client).not_to receive(:wait_for)
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_firewall_get'
3
+
4
+ Chef::Knife::IonoscloudFirewallGet.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudFirewallGet do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudFirewallGet.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 FirewallRulesApi.datacenters_servers_nics_firewallrules_find_by_id' do
16
+ firewall = firewall_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ datacenter_id: 'datacenter_id',
21
+ server_id: 'server_id',
22
+ nic_id: 'nic_id',
23
+ firewall_id: firewall.id,
24
+ yes: true,
25
+ }
26
+
27
+ subject_config.each { |key, value| subject.config[key] = value }
28
+
29
+ expect(subject).to receive(:puts).with("ID: #{firewall.id}")
30
+ expect(subject).to receive(:puts).with("Name: #{firewall.properties.name}")
31
+ expect(subject).to receive(:puts).with("Type: #{firewall.properties.type}")
32
+ expect(subject).to receive(:puts).with("Protocol: #{firewall.properties.protocol}")
33
+ expect(subject).to receive(:puts).with("Source MAC: #{firewall.properties.source_mac}")
34
+ expect(subject).to receive(:puts).with("Source IP: #{firewall.properties.source_ip}")
35
+ expect(subject).to receive(:puts).with("Target IP: #{firewall.properties.target_ip}")
36
+ expect(subject).to receive(:puts).with("Port Range Start: #{firewall.properties.port_range_start}")
37
+ expect(subject).to receive(:puts).with("Port Range End: #{firewall.properties.port_range_end}")
38
+ expect(subject).to receive(:puts).with("ICMP Type: #{firewall.properties.icmp_type}")
39
+ expect(subject).to receive(:puts).with("ICMP Code: #{firewall.properties.icmp_code}")
40
+
41
+ expect(subject.api_client).not_to receive(:wait_for)
42
+ mock_call_api(
43
+ subject,
44
+ [
45
+ {
46
+ method: 'GET',
47
+ path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{subject_config[:server_id]}/"\
48
+ "nics/#{subject_config[:nic_id]}/firewallrules/#{firewall.id}",
49
+ operation: :'FirewallRulesApi.datacenters_servers_nics_firewallrules_find_by_id',
50
+ return_type: 'FirewallRule',
51
+ result: firewall,
52
+ },
53
+ ],
54
+ )
55
+
56
+ expect { subject.run }.not_to raise_error(Exception)
57
+ end
58
+
59
+ it 'should not make any call if any required option is missing' do
60
+ required_options = subject.instance_variable_get(:@required_options)
61
+
62
+ arrays_without_one_element(required_options).each do |test_case|
63
+
64
+ test_case[:array].each { |value| subject.config[value] = 'test' }
65
+
66
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
67
+ expect(subject.api_client).not_to receive(:call_api)
68
+
69
+ expect { subject.run }.to raise_error(SystemExit) do |error|
70
+ expect(error.status).to eq(1)
71
+ end
72
+
73
+ required_options.each { |value| subject.config[value] = nil }
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,117 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_firewall_update'
3
+
4
+ Chef::Knife::IonoscloudFirewallUpdate.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudFirewallUpdate do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudFirewallUpdate.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 FirewallRulesApi.datacenters_servers_nics_firewallrules_patch' do
16
+ firewall = firewall_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ datacenter_id: 'datacenter_id',
21
+ server_id: 'server_id',
22
+ nic_id: 'nic_id',
23
+ firewall_id: firewall.id,
24
+ name: firewall.properties.name + '_edited',
25
+ protocol: 'TCP',
26
+ source_mac: '01:11:11:11:22:00',
27
+ source_ip: '1.2.3.4',
28
+ target_ip: '2.2.3.1',
29
+ port_range_start: 100,
30
+ port_range_end: 145,
31
+ icmp_type: 15,
32
+ icmp_code: 14,
33
+ yes: true,
34
+ }
35
+
36
+ subject_config.each { |key, value| subject.config[key] = value }
37
+
38
+ expect(subject).to receive(:puts).with("ID: #{firewall.id}")
39
+ expect(subject).to receive(:puts).with("Name: #{subject_config[:name]}")
40
+ expect(subject).to receive(:puts).with("Type: #{firewall.properties.type}")
41
+ expect(subject).to receive(:puts).with("Protocol: #{subject_config[:protocol]}")
42
+ expect(subject).to receive(:puts).with("Source MAC: #{subject_config[:source_mac]}")
43
+ expect(subject).to receive(:puts).with("Source IP: #{subject_config[:source_ip]}")
44
+ expect(subject).to receive(:puts).with("Target IP: #{subject_config[:target_ip]}")
45
+ expect(subject).to receive(:puts).with("Port Range Start: #{subject_config[:port_range_start]}")
46
+ expect(subject).to receive(:puts).with("Port Range End: #{subject_config[:port_range_end]}")
47
+ expect(subject).to receive(:puts).with("ICMP Type: #{subject_config[:icmp_type]}")
48
+ expect(subject).to receive(:puts).with("ICMP Code: #{subject_config[:icmp_code]}")
49
+
50
+ firewall.properties.name = subject_config[:name]
51
+ firewall.properties.protocol = subject_config[:protocol]
52
+ firewall.properties.source_mac = subject_config[:source_mac]
53
+ firewall.properties.source_ip = subject_config[:source_ip]
54
+ firewall.properties.target_ip = subject_config[:target_ip]
55
+ firewall.properties.port_range_start = subject_config[:port_range_start]
56
+ firewall.properties.port_range_end = subject_config[:port_range_end]
57
+ firewall.properties.icmp_type = subject_config[:icmp_type]
58
+ firewall.properties.icmp_code = subject_config[:icmp_code]
59
+
60
+ expected_body = {
61
+ name: subject_config[:name],
62
+ protocol: subject_config[:protocol],
63
+ sourceMac: subject_config[:source_mac],
64
+ sourceIp: subject_config[:source_ip],
65
+ targetIp: subject_config[:target_ip],
66
+ portRangeStart: subject_config[:port_range_start],
67
+ portRangeEnd: subject_config[:port_range_end],
68
+ icmpType: subject_config[:icmp_type],
69
+ icmpCode: subject_config[:icmp_code],
70
+ }
71
+
72
+ mock_wait_for(subject)
73
+ mock_call_api(
74
+ subject,
75
+ [
76
+ {
77
+ method: 'PATCH',
78
+ path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{subject_config[:server_id]}/"\
79
+ "nics/#{subject_config[:nic_id]}/firewallrules/#{firewall.id}",
80
+ operation: :'FirewallRulesApi.datacenters_servers_nics_firewallrules_patch',
81
+ return_type: 'FirewallRule',
82
+ body: expected_body,
83
+ result: firewall,
84
+ },
85
+ {
86
+ method: 'GET',
87
+ path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{subject_config[:server_id]}/"\
88
+ "nics/#{subject_config[:nic_id]}/firewallrules/#{firewall.id}",
89
+ operation: :'FirewallRulesApi.datacenters_servers_nics_firewallrules_find_by_id',
90
+ return_type: 'FirewallRule',
91
+ result: firewall,
92
+ },
93
+ ],
94
+ )
95
+
96
+ expect { subject.run }.not_to raise_error(Exception)
97
+ end
98
+
99
+ it 'should not make any call if any required option is missing' do
100
+ required_options = subject.instance_variable_get(:@required_options)
101
+
102
+ arrays_without_one_element(required_options).each do |test_case|
103
+
104
+ test_case[:array].each { |value| subject.config[value] = 'test' }
105
+
106
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
107
+ expect(subject.api_client).not_to receive(:call_api)
108
+
109
+ expect { subject.run }.to raise_error(SystemExit) do |error|
110
+ expect(error.status).to eq(1)
111
+ end
112
+
113
+ required_options.each { |value| subject.config[value] = nil }
114
+ end
115
+ end
116
+ end
117
+ end