knife-ionoscloud 5.1.0 → 6.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/knife-ionoscloud.gemspec +1 -1
- data/lib/chef/knife/ionoscloud_backupunit_create.rb +1 -1
- data/lib/chef/knife/ionoscloud_backupunit_delete.rb +1 -1
- data/lib/chef/knife/ionoscloud_backupunit_list.rb +1 -1
- data/lib/chef/knife/ionoscloud_backupunit_ssourl.rb +1 -1
- data/lib/chef/knife/ionoscloud_base.rb +1 -1
- data/lib/chef/knife/ionoscloud_composite_server_create.rb +25 -23
- data/lib/chef/knife/ionoscloud_contract_list.rb +32 -23
- data/lib/chef/knife/ionoscloud_cube_server_create.rb +215 -0
- data/lib/chef/knife/ionoscloud_datacenter_create.rb +1 -1
- data/lib/chef/knife/ionoscloud_datacenter_delete.rb +1 -1
- data/lib/chef/knife/ionoscloud_datacenter_list.rb +4 -2
- data/lib/chef/knife/ionoscloud_firewall_create.rb +11 -4
- data/lib/chef/knife/ionoscloud_firewall_delete.rb +4 -3
- data/lib/chef/knife/ionoscloud_firewall_list.rb +5 -3
- data/lib/chef/knife/ionoscloud_flowlog_create.rb +121 -0
- data/lib/chef/knife/ionoscloud_flowlog_delete.rb +106 -0
- data/lib/chef/knife/ionoscloud_flowlog_list.rb +100 -0
- data/lib/chef/knife/ionoscloud_group_create.rb +35 -14
- data/lib/chef/knife/ionoscloud_group_delete.rb +7 -0
- data/lib/chef/knife/ionoscloud_group_get.rb +6 -0
- data/lib/chef/knife/ionoscloud_group_list.rb +19 -7
- data/lib/chef/knife/ionoscloud_image_list.rb +1 -1
- data/lib/chef/knife/ionoscloud_ipfailover_add.rb +1 -1
- data/lib/chef/knife/ionoscloud_ipfailover_remove.rb +1 -1
- data/lib/chef/knife/ionoscloud_k8s_delete.rb +5 -2
- data/lib/chef/knife/ionoscloud_label_add.rb +1 -1
- data/lib/chef/knife/ionoscloud_label_list.rb +1 -1
- data/lib/chef/knife/ionoscloud_label_remove.rb +1 -1
- data/lib/chef/knife/ionoscloud_lan_create.rb +1 -1
- data/lib/chef/knife/ionoscloud_lan_delete.rb +1 -1
- data/lib/chef/knife/ionoscloud_lan_list.rb +1 -1
- data/lib/chef/knife/ionoscloud_loadbalancer_create.rb +1 -1
- data/lib/chef/knife/ionoscloud_loadbalancer_delete.rb +1 -1
- data/lib/chef/knife/ionoscloud_loadbalancer_get.rb +1 -1
- data/lib/chef/knife/ionoscloud_loadbalancer_list.rb +1 -1
- data/lib/chef/knife/ionoscloud_loadbalancer_nic_add.rb +1 -1
- data/lib/chef/knife/ionoscloud_loadbalancer_nic_remove.rb +1 -1
- data/lib/chef/knife/ionoscloud_location_list.rb +5 -3
- data/lib/chef/knife/ionoscloud_natgateway_create.rb +71 -0
- data/lib/chef/knife/ionoscloud_natgateway_delete.rb +69 -0
- data/lib/chef/knife/ionoscloud_natgateway_lan_add.rb +82 -0
- data/lib/chef/knife/ionoscloud_natgateway_lan_remove.rb +58 -0
- data/lib/chef/knife/ionoscloud_natgateway_list.rb +49 -0
- data/lib/chef/knife/ionoscloud_natgateway_rule_add.rb +124 -0
- data/lib/chef/knife/ionoscloud_natgateway_rule_list.rb +63 -0
- data/lib/chef/knife/ionoscloud_natgateway_rule_remove.rb +72 -0
- data/lib/chef/knife/ionoscloud_networkloadbalancer_create.rb +95 -0
- data/lib/chef/knife/ionoscloud_networkloadbalancer_delete.rb +81 -0
- data/lib/chef/knife/ionoscloud_networkloadbalancer_list.rb +56 -0
- data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_add.rb +150 -0
- data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_list.rb +63 -0
- data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_remove.rb +78 -0
- data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_add.rb +141 -0
- data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_list.rb +68 -0
- data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove.rb +105 -0
- data/lib/chef/knife/ionoscloud_nic_create.rb +14 -9
- data/lib/chef/knife/ionoscloud_nic_delete.rb +4 -2
- data/lib/chef/knife/ionoscloud_nic_list.rb +9 -5
- data/lib/chef/knife/ionoscloud_node_list.rb +0 -1
- data/lib/chef/knife/ionoscloud_nodepool_create.rb +42 -16
- data/lib/chef/knife/ionoscloud_nodepool_delete.rb +25 -0
- data/lib/chef/knife/ionoscloud_nodepool_lan_add.rb +130 -0
- data/lib/chef/knife/ionoscloud_nodepool_lan_remove.rb +96 -0
- data/lib/chef/knife/ionoscloud_nodepool_list.rb +3 -1
- data/lib/chef/knife/ionoscloud_pcc_create.rb +2 -2
- data/lib/chef/knife/ionoscloud_pcc_delete.rb +1 -1
- data/lib/chef/knife/ionoscloud_pcc_list.rb +1 -1
- data/lib/chef/knife/ionoscloud_request_list.rb +1 -1
- data/lib/chef/knife/ionoscloud_request_status.rb +1 -1
- data/lib/chef/knife/ionoscloud_s3key_create.rb +2 -2
- data/lib/chef/knife/ionoscloud_s3key_delete.rb +3 -3
- data/lib/chef/knife/ionoscloud_s3key_list.rb +2 -2
- data/lib/chef/knife/ionoscloud_server_console.rb +42 -0
- data/lib/chef/knife/ionoscloud_server_create.rb +8 -8
- data/lib/chef/knife/ionoscloud_server_delete.rb +1 -1
- data/lib/chef/knife/ionoscloud_server_list.rb +16 -5
- data/lib/chef/knife/ionoscloud_server_reboot.rb +1 -1
- data/lib/chef/knife/ionoscloud_server_resume.rb +43 -0
- data/lib/chef/knife/ionoscloud_server_start.rb +1 -1
- data/lib/chef/knife/ionoscloud_server_stop.rb +1 -1
- data/lib/chef/knife/ionoscloud_server_suspend.rb +44 -0
- data/lib/chef/knife/ionoscloud_server_token.rb +42 -0
- data/lib/chef/knife/ionoscloud_server_upgrade.rb +44 -0
- data/lib/chef/knife/ionoscloud_snapshot_create.rb +2 -2
- data/lib/chef/knife/ionoscloud_snapshot_delete.rb +1 -1
- data/lib/chef/knife/ionoscloud_snapshot_list.rb +1 -1
- data/lib/chef/knife/ionoscloud_snapshot_restore.rb +2 -2
- data/lib/chef/knife/ionoscloud_template_list.rb +46 -0
- data/lib/chef/knife/ionoscloud_user_ssourl.rb +1 -1
- data/lib/chef/knife/ionoscloud_volume_attach.rb +1 -1
- data/lib/chef/knife/ionoscloud_volume_create.rb +33 -35
- data/lib/chef/knife/ionoscloud_volume_delete.rb +1 -1
- data/lib/chef/knife/ionoscloud_volume_detach.rb +1 -1
- data/lib/chef/knife/ionoscloud_volume_list.rb +2 -2
- data/lib/knife-ionoscloud/version.rb +1 -1
- data/spec/chef/knife/ionoscloud_backupunit_create_spec.rb +2 -2
- data/spec/chef/knife/ionoscloud_backupunit_delete_spec.rb +5 -5
- data/spec/chef/knife/ionoscloud_backupunit_list_spec.rb +1 -1
- data/spec/chef/knife/ionoscloud_backupunit_ssourl_spec.rb +3 -3
- data/spec/chef/knife/ionoscloud_base_spec.rb +4 -4
- data/spec/chef/knife/ionoscloud_composite_server_create_spec.rb +11 -8
- data/spec/chef/knife/ionoscloud_contract_list_spec.rb +32 -27
- data/spec/chef/knife/ionoscloud_cube_server_create_spec.rb +249 -0
- data/spec/chef/knife/ionoscloud_datacenter_create_spec.rb +3 -2
- data/spec/chef/knife/ionoscloud_datacenter_delete_spec.rb +5 -5
- data/spec/chef/knife/ionoscloud_datacenter_list_spec.rb +5 -3
- data/spec/chef/knife/ionoscloud_firewall_create_spec.rb +5 -3
- data/spec/chef/knife/ionoscloud_firewall_delete_spec.rb +6 -5
- data/spec/chef/knife/ionoscloud_firewall_list_spec.rb +5 -3
- data/spec/chef/knife/ionoscloud_flowlog_create_spec.rb +254 -0
- data/spec/chef/knife/ionoscloud_flowlog_delete_spec.rb +360 -0
- data/spec/chef/knife/ionoscloud_flowlog_list_spec.rb +264 -0
- data/spec/chef/knife/ionoscloud_group_create_spec.rb +6 -0
- data/spec/chef/knife/ionoscloud_group_delete_spec.rb +6 -0
- data/spec/chef/knife/ionoscloud_group_get_spec.rb +6 -0
- data/spec/chef/knife/ionoscloud_group_list_spec.rb +26 -8
- data/spec/chef/knife/ionoscloud_image_list_spec.rb +2 -2
- data/spec/chef/knife/ionoscloud_ipfailover_add_spec.rb +3 -3
- data/spec/chef/knife/ionoscloud_ipfailover_remove_spec.rb +4 -4
- data/spec/chef/knife/ionoscloud_k8s_delete_spec.rb +5 -2
- data/spec/chef/knife/ionoscloud_kubeconfig_get_spec.rb +2 -2
- data/spec/chef/knife/ionoscloud_label_add_spec.rb +10 -10
- data/spec/chef/knife/ionoscloud_label_list_spec.rb +14 -14
- data/spec/chef/knife/ionoscloud_label_remove_spec.rb +20 -20
- data/spec/chef/knife/ionoscloud_lan_create_spec.rb +3 -3
- data/spec/chef/knife/ionoscloud_lan_delete_spec.rb +5 -5
- data/spec/chef/knife/ionoscloud_lan_list_spec.rb +2 -2
- data/spec/chef/knife/ionoscloud_loadbalancer_create_spec.rb +3 -3
- data/spec/chef/knife/ionoscloud_loadbalancer_delete_spec.rb +5 -5
- data/spec/chef/knife/ionoscloud_loadbalancer_get_spec.rb +2 -2
- data/spec/chef/knife/ionoscloud_loadbalancer_list_spec.rb +2 -2
- data/spec/chef/knife/ionoscloud_loadbalancer_nic_add_spec.rb +6 -6
- data/spec/chef/knife/ionoscloud_loadbalancer_nic_remove_spec.rb +6 -6
- data/spec/chef/knife/ionoscloud_location_list_spec.rb +5 -3
- data/spec/chef/knife/ionoscloud_natgateway_create_spec.rb +77 -0
- data/spec/chef/knife/ionoscloud_natgateway_delete_spec.rb +118 -0
- data/spec/chef/knife/ionoscloud_natgateway_lan_add_spec.rb +143 -0
- data/spec/chef/knife/ionoscloud_natgateway_lan_remove_spec.rb +194 -0
- data/spec/chef/knife/ionoscloud_natgateway_list_spec.rb +79 -0
- data/spec/chef/knife/ionoscloud_natgateway_rule_add_spec.rb +98 -0
- data/spec/chef/knife/ionoscloud_natgateway_rule_list_spec.rb +92 -0
- data/spec/chef/knife/ionoscloud_natgateway_rule_remove_spec.rb +77 -0
- data/spec/chef/knife/ionoscloud_networkloadbalancer_create_spec.rb +80 -0
- data/spec/chef/knife/ionoscloud_networkloadbalancer_delete_spec.rb +119 -0
- data/spec/chef/knife/ionoscloud_networkloadbalancer_list_spec.rb +88 -0
- data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_add_spec.rb +104 -0
- data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_list_spec.rb +89 -0
- data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_remove_spec.rb +124 -0
- data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_add_spec.rb +109 -0
- data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_list_spec.rb +85 -0
- data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove_spec.rb +263 -0
- data/spec/chef/knife/ionoscloud_nic_create_spec.rb +9 -5
- data/spec/chef/knife/ionoscloud_nic_delete_spec.rb +8 -6
- data/spec/chef/knife/ionoscloud_nic_list_spec.rb +12 -6
- data/spec/chef/knife/ionoscloud_nodepool_create_spec.rb +15 -1
- data/spec/chef/knife/ionoscloud_nodepool_lan_add_spec.rb +226 -0
- data/spec/chef/knife/ionoscloud_nodepool_lan_remove.rb +199 -0
- data/spec/chef/knife/ionoscloud_nodepool_list_spec.rb +3 -1
- data/spec/chef/knife/ionoscloud_pcc_create_spec.rb +6 -6
- data/spec/chef/knife/ionoscloud_pcc_delete_spec.rb +5 -5
- data/spec/chef/knife/ionoscloud_pcc_list_spec.rb +2 -2
- data/spec/chef/knife/ionoscloud_request_list_spec.rb +16 -16
- data/spec/chef/knife/ionoscloud_request_status_spec.rb +3 -3
- data/spec/chef/knife/ionoscloud_s3key_create_spec.rb +2 -2
- data/spec/chef/knife/ionoscloud_s3key_delete_spec.rb +5 -5
- data/spec/chef/knife/ionoscloud_s3key_list_spec.rb +2 -2
- data/spec/chef/knife/ionoscloud_server_console_spec.rb +97 -0
- data/spec/chef/knife/ionoscloud_server_create_spec.rb +3 -3
- data/spec/chef/knife/ionoscloud_server_delete_spec.rb +5 -5
- data/spec/chef/knife/ionoscloud_server_list_spec.rb +63 -5
- data/spec/chef/knife/ionoscloud_server_reboot_spec.rb +3 -5
- data/spec/chef/knife/ionoscloud_server_resume_spec.rb +93 -0
- data/spec/chef/knife/ionoscloud_server_start_spec.rb +3 -5
- data/spec/chef/knife/ionoscloud_server_stop_spec.rb +3 -5
- data/spec/chef/knife/ionoscloud_server_suspend_spec.rb +93 -0
- data/spec/chef/knife/ionoscloud_server_token_spec.rb +97 -0
- data/spec/chef/knife/ionoscloud_server_upgrade_spec.rb +96 -0
- data/spec/chef/knife/ionoscloud_snapshot_create_spec.rb +3 -3
- data/spec/chef/knife/ionoscloud_snapshot_delete_spec.rb +5 -5
- data/spec/chef/knife/ionoscloud_snapshot_list_spec.rb +2 -2
- data/spec/chef/knife/ionoscloud_snapshot_restore_spec.rb +3 -3
- data/spec/chef/knife/ionoscloud_template_list_spec.rb +78 -0
- data/spec/chef/knife/ionoscloud_user_ssourl_spec.rb +3 -3
- data/spec/chef/knife/ionoscloud_volume_attach_spec.rb +4 -4
- data/spec/chef/knife/ionoscloud_volume_create_spec.rb +6 -58
- data/spec/chef/knife/ionoscloud_volume_delete_spec.rb +5 -5
- data/spec/chef/knife/ionoscloud_volume_detach_spec.rb +5 -5
- data/spec/chef/knife/ionoscloud_volume_list_spec.rb +4 -4
- data/spec/spec_helper.rb +223 -29
- metadata +93 -6
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ionoscloud_server_upgrade'
|
3
|
+
|
4
|
+
Chef::Knife::IonoscloudServerUpgrade.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::IonoscloudServerUpgrade do
|
7
|
+
before :each do
|
8
|
+
subject { Chef::Knife::IonoscloudServerUpgrade.new }
|
9
|
+
|
10
|
+
allow(subject).to receive(:puts)
|
11
|
+
allow(subject).to receive(:print)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#run' do
|
15
|
+
it 'should output success when the ID is valid' do
|
16
|
+
server = server_mock
|
17
|
+
subject_config = {
|
18
|
+
ionoscloud_username: 'email',
|
19
|
+
ionoscloud_password: 'password',
|
20
|
+
datacenter_id: 'datacenter_id',
|
21
|
+
server_id: server.id,
|
22
|
+
yes: true,
|
23
|
+
}
|
24
|
+
|
25
|
+
subject_config.each { |key, value| subject.config[key] = value }
|
26
|
+
subject.name_args = [server.id]
|
27
|
+
|
28
|
+
expect(subject.ui).to receive(:info).with("Server #{server.id} is being upgraded. Request ID: ")
|
29
|
+
|
30
|
+
expect(subject.api_client).not_to receive(:wait_for)
|
31
|
+
expect(subject).to receive(:get_request_id).once
|
32
|
+
|
33
|
+
mock_call_api(
|
34
|
+
subject,
|
35
|
+
[
|
36
|
+
{
|
37
|
+
method: 'POST',
|
38
|
+
path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{server.id}/upgrade",
|
39
|
+
operation: :'ServersApi.datacenters_servers_upgrade_post',
|
40
|
+
result: server,
|
41
|
+
},
|
42
|
+
],
|
43
|
+
)
|
44
|
+
|
45
|
+
expect { subject.run }.not_to raise_error(Exception)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should output failure when the server ID is not valid' do
|
49
|
+
server_id = 'invalid_id'
|
50
|
+
subject_config = {
|
51
|
+
ionoscloud_username: 'email',
|
52
|
+
ionoscloud_password: 'password',
|
53
|
+
datacenter_id: 'datacenter_id',
|
54
|
+
server_id: server_id,
|
55
|
+
}
|
56
|
+
|
57
|
+
subject_config.each { |key, value| subject.config[key] = value }
|
58
|
+
subject.name_args = [server_id]
|
59
|
+
|
60
|
+
expect(subject.ui).to receive(:error).with("Server ID #{server_id} not found.")
|
61
|
+
|
62
|
+
expect(subject.api_client).not_to receive(:wait_for)
|
63
|
+
mock_call_api(
|
64
|
+
subject,
|
65
|
+
[
|
66
|
+
{
|
67
|
+
method: 'POST',
|
68
|
+
path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{server_id}/upgrade",
|
69
|
+
operation: :'ServersApi.datacenters_servers_upgrade_post',
|
70
|
+
exception: Ionoscloud::ApiError.new(code: 404),
|
71
|
+
},
|
72
|
+
],
|
73
|
+
)
|
74
|
+
|
75
|
+
expect { subject.run }.not_to raise_error(Exception)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should not make any call if any required option is missing' do
|
79
|
+
required_options = subject.instance_variable_get(:@required_options)
|
80
|
+
|
81
|
+
arrays_without_one_element(required_options).each do |test_case|
|
82
|
+
|
83
|
+
test_case[:array].each { |value| subject.config[value] = 'test' }
|
84
|
+
|
85
|
+
expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
|
86
|
+
expect(subject.api_client).not_to receive(:call_api)
|
87
|
+
|
88
|
+
expect { subject.run }.to raise_error(SystemExit) do |error|
|
89
|
+
expect(error.status).to eq(1)
|
90
|
+
end
|
91
|
+
|
92
|
+
required_options.each { |value| subject.config[value] = nil }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -12,7 +12,7 @@ describe Chef::Knife::IonoscloudSnapshotCreate do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#run' do
|
15
|
-
it 'should call
|
15
|
+
it 'should call VolumesApi.datacenters_volumes_create_snapshot_post with the expected arguments and output based on what it receives' do
|
16
16
|
snapshot = snapshot_mock
|
17
17
|
subject_config = {
|
18
18
|
ionoscloud_username: 'email',
|
@@ -40,7 +40,7 @@ describe Chef::Knife::IonoscloudSnapshotCreate do
|
|
40
40
|
{
|
41
41
|
method: 'POST',
|
42
42
|
path: "/datacenters/#{subject_config[:datacenter_id]}/volumes/#{subject_config[:volume_id]}/create-snapshot",
|
43
|
-
operation: :'
|
43
|
+
operation: :'VolumesApi.datacenters_volumes_create_snapshot_post',
|
44
44
|
return_type: 'Snapshot',
|
45
45
|
result: snapshot,
|
46
46
|
form_params: {
|
@@ -53,7 +53,7 @@ describe Chef::Knife::IonoscloudSnapshotCreate do
|
|
53
53
|
{
|
54
54
|
method: 'GET',
|
55
55
|
path: "/snapshots/#{snapshot.id}",
|
56
|
-
operation: :'
|
56
|
+
operation: :'SnapshotsApi.snapshots_find_by_id',
|
57
57
|
return_type: 'Snapshot',
|
58
58
|
result: snapshot,
|
59
59
|
},
|
@@ -12,7 +12,7 @@ describe Chef::Knife::IonoscloudSnapshotDelete do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#run' do
|
15
|
-
it 'should call
|
15
|
+
it 'should call SnapshotsApi.snapshots_delete when the ID is valid' do
|
16
16
|
snapshot = snapshot_mock
|
17
17
|
subject_config = {
|
18
18
|
ionoscloud_username: 'email',
|
@@ -38,14 +38,14 @@ describe Chef::Knife::IonoscloudSnapshotDelete do
|
|
38
38
|
{
|
39
39
|
method: 'GET',
|
40
40
|
path: "/snapshots/#{snapshot.id}",
|
41
|
-
operation: :'
|
41
|
+
operation: :'SnapshotsApi.snapshots_find_by_id',
|
42
42
|
return_type: 'Snapshot',
|
43
43
|
result: snapshot,
|
44
44
|
},
|
45
45
|
{
|
46
46
|
method: 'DELETE',
|
47
47
|
path: "/snapshots/#{snapshot.id}",
|
48
|
-
operation: :'
|
48
|
+
operation: :'SnapshotsApi.snapshots_delete',
|
49
49
|
},
|
50
50
|
],
|
51
51
|
)
|
@@ -53,7 +53,7 @@ describe Chef::Knife::IonoscloudSnapshotDelete do
|
|
53
53
|
expect { subject.run }.not_to raise_error(Exception)
|
54
54
|
end
|
55
55
|
|
56
|
-
it 'should not call
|
56
|
+
it 'should not call SnapshotsApi.snapshots_delete when the user ID is not valid' do
|
57
57
|
snapshot_id = 'invalid_id'
|
58
58
|
subject_config = {
|
59
59
|
ionoscloud_username: 'email',
|
@@ -72,7 +72,7 @@ describe Chef::Knife::IonoscloudSnapshotDelete do
|
|
72
72
|
{
|
73
73
|
method: 'GET',
|
74
74
|
path: "/snapshots/#{snapshot_id}",
|
75
|
-
operation: :'
|
75
|
+
operation: :'SnapshotsApi.snapshots_find_by_id',
|
76
76
|
return_type: 'Snapshot',
|
77
77
|
exception: Ionoscloud::ApiError.new(code: 404),
|
78
78
|
},
|
@@ -12,7 +12,7 @@ describe Chef::Knife::IonoscloudSnapshotList do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#run' do
|
15
|
-
it 'should call
|
15
|
+
it 'should call SnapshotsApi.snapshots_get' do
|
16
16
|
snapshots = snapshots_mock
|
17
17
|
subject_config = {
|
18
18
|
ionoscloud_username: 'email',
|
@@ -42,7 +42,7 @@ describe Chef::Knife::IonoscloudSnapshotList do
|
|
42
42
|
{
|
43
43
|
method: 'GET',
|
44
44
|
path: '/snapshots',
|
45
|
-
operation: :'
|
45
|
+
operation: :'SnapshotsApi.snapshots_get',
|
46
46
|
return_type: 'Snapshots',
|
47
47
|
result: snapshots,
|
48
48
|
},
|
@@ -12,7 +12,7 @@ describe Chef::Knife::IonoscloudSnapshotRestore do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#run' do
|
15
|
-
it 'should call
|
15
|
+
it 'should call VolumesApi.datacenters_volumes_create_snapshot_post with the expected arguments and output based on what it receives' do
|
16
16
|
snapshot = snapshot_mock
|
17
17
|
volume = volume_mock
|
18
18
|
subject_config = {
|
@@ -41,13 +41,13 @@ describe Chef::Knife::IonoscloudSnapshotRestore do
|
|
41
41
|
{
|
42
42
|
method: 'POST',
|
43
43
|
path: "/datacenters/#{subject_config[:datacenter_id]}/volumes/#{volume.id}/restore-snapshot",
|
44
|
-
operation: :'
|
44
|
+
operation: :'VolumesApi.datacenters_volumes_restore_snapshot_post',
|
45
45
|
form_params: { 'snapshotId' => snapshot.id },
|
46
46
|
},
|
47
47
|
{
|
48
48
|
method: 'GET',
|
49
49
|
path: "/datacenters/#{subject_config[:datacenter_id]}/volumes/#{volume.id}",
|
50
|
-
operation: :'
|
50
|
+
operation: :'VolumesApi.datacenters_volumes_find_by_id',
|
51
51
|
return_type: 'Volume',
|
52
52
|
result: volume,
|
53
53
|
},
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ionoscloud_template_list'
|
3
|
+
|
4
|
+
Chef::Knife::IonoscloudTemplateList.load_deps
|
5
|
+
|
6
|
+
describe Chef::Knife::IonoscloudTemplateList do
|
7
|
+
before :each do
|
8
|
+
subject { Chef::Knife::IonoscloudTemplateList.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 TemplatesApi.templates_get' do
|
16
|
+
templates = templates_mock
|
17
|
+
subject_config = {
|
18
|
+
ionoscloud_username: 'email',
|
19
|
+
ionoscloud_password: 'password',
|
20
|
+
}
|
21
|
+
|
22
|
+
subject_config.each { |key, value| subject.config[key] = value }
|
23
|
+
|
24
|
+
template_list = [
|
25
|
+
subject.ui.color('ID', :bold),
|
26
|
+
subject.ui.color('Name', :bold),
|
27
|
+
subject.ui.color('Cores', :bold),
|
28
|
+
subject.ui.color('RAM', :bold),
|
29
|
+
subject.ui.color('Storage Size', :bold),
|
30
|
+
templates.items[0].id,
|
31
|
+
templates.items[0].properties.name,
|
32
|
+
Integer(templates.items[0].properties.cores),
|
33
|
+
Integer(templates.items[0].properties.ram),
|
34
|
+
Integer(templates.items[0].properties.storage_size),
|
35
|
+
templates.items[1].id,
|
36
|
+
templates.items[1].properties.name,
|
37
|
+
Integer(templates.items[1].properties.cores),
|
38
|
+
Integer(templates.items[1].properties.ram),
|
39
|
+
Integer(templates.items[1].properties.storage_size),
|
40
|
+
]
|
41
|
+
|
42
|
+
expect(subject.ui).to receive(:list).with(template_list, :uneven_columns_across, 5)
|
43
|
+
|
44
|
+
mock_call_api(
|
45
|
+
subject,
|
46
|
+
[
|
47
|
+
{
|
48
|
+
method: 'GET',
|
49
|
+
path: '/templates',
|
50
|
+
operation: :'TemplatesApi.templates_get',
|
51
|
+
return_type: 'Templates',
|
52
|
+
result: templates,
|
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
|
@@ -7,7 +7,7 @@ describe Chef::Knife::IonoscloudUserSsourl do
|
|
7
7
|
subject { Chef::Knife::IonoscloudUserSsourl.new }
|
8
8
|
|
9
9
|
describe '#run' do
|
10
|
-
it 'should call
|
10
|
+
it 'should call UserS3KeysApi.um_users_ssourl_get and output the received url when the user ID is valid' do
|
11
11
|
user = user_mock
|
12
12
|
sso_url = sso_url_mock
|
13
13
|
subject_config = {
|
@@ -27,7 +27,7 @@ describe Chef::Knife::IonoscloudUserSsourl do
|
|
27
27
|
{
|
28
28
|
method: 'GET',
|
29
29
|
path: "/um/users/#{user.id}/s3ssourl",
|
30
|
-
operation: :'
|
30
|
+
operation: :'UserS3KeysApi.um_users_s3ssourl_get',
|
31
31
|
return_type: 'S3ObjectStorageSSO',
|
32
32
|
result: sso_url,
|
33
33
|
},
|
@@ -59,7 +59,7 @@ describe Chef::Knife::IonoscloudUserSsourl do
|
|
59
59
|
{
|
60
60
|
method: 'GET',
|
61
61
|
path: "/um/users/#{user_id}/s3ssourl",
|
62
|
-
operation: :'
|
62
|
+
operation: :'UserS3KeysApi.um_users_s3ssourl_get',
|
63
63
|
return_type: 'S3ObjectStorageSSO',
|
64
64
|
exception: Ionoscloud::ApiError.new(code: 404),
|
65
65
|
},
|
@@ -12,7 +12,7 @@ describe Chef::Knife::IonoscloudVolumeAttach do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#run' do
|
15
|
-
it 'should call
|
15
|
+
it 'should call ServersApi.datacenters_servers_volumes_post when the ID is valid' do
|
16
16
|
volume = volume_mock
|
17
17
|
subject_config = {
|
18
18
|
ionoscloud_username: 'email',
|
@@ -35,7 +35,7 @@ describe Chef::Knife::IonoscloudVolumeAttach do
|
|
35
35
|
{
|
36
36
|
method: 'POST',
|
37
37
|
path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{subject_config[:server_id]}/volumes",
|
38
|
-
operation: :'
|
38
|
+
operation: :'ServersApi.datacenters_servers_volumes_post',
|
39
39
|
body: { id: volume.id },
|
40
40
|
return_type: 'Volume',
|
41
41
|
result: volume,
|
@@ -46,7 +46,7 @@ describe Chef::Knife::IonoscloudVolumeAttach do
|
|
46
46
|
expect { subject.run }.not_to raise_error(Exception)
|
47
47
|
end
|
48
48
|
|
49
|
-
it 'should not call
|
49
|
+
it 'should not call ServersApi.datacenters_servers_volumes_post when the ID is not valid' do
|
50
50
|
volume_id = 'invalid_id'
|
51
51
|
subject_config = {
|
52
52
|
ionoscloud_username: 'email',
|
@@ -67,7 +67,7 @@ describe Chef::Knife::IonoscloudVolumeAttach do
|
|
67
67
|
{
|
68
68
|
method: 'POST',
|
69
69
|
path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{subject_config[:server_id]}/volumes",
|
70
|
-
operation: :'
|
70
|
+
operation: :'ServersApi.datacenters_servers_volumes_post',
|
71
71
|
body: { id: volume_id },
|
72
72
|
return_type: 'Volume',
|
73
73
|
exception: Ionoscloud::ApiError.new(code: 404),
|
@@ -12,7 +12,7 @@ describe Chef::Knife::IonoscloudVolumeCreate do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#run' do
|
15
|
-
it 'should call
|
15
|
+
it 'should call VolumesApi.datacenters_volumes_post with the expected arguments and output based on what it receives' do
|
16
16
|
volume = volume_mock
|
17
17
|
subject_config = {
|
18
18
|
ionoscloud_username: 'email',
|
@@ -23,17 +23,17 @@ describe Chef::Knife::IonoscloudVolumeCreate do
|
|
23
23
|
type: volume.properties.type,
|
24
24
|
bus: volume.properties.bus,
|
25
25
|
availability_zone: volume.properties.availability_zone,
|
26
|
-
image_alias: 'debian:latest',
|
27
26
|
image_password: 'K3tTj8G14a3EgKyNeeiY',
|
27
|
+
image: volume.properties.image,
|
28
|
+
backupunit_id: volume.properties.backupunit_id,
|
29
|
+
user_data: volume.properties.user_data,
|
28
30
|
}
|
29
31
|
|
30
32
|
subject_config.each { |key, value| subject.config[key] = value }
|
31
33
|
|
32
34
|
expected_body = volume.properties.to_hash
|
33
|
-
expected_body.delete(:image)
|
34
35
|
expected_body.delete(:licenceType)
|
35
36
|
|
36
|
-
expected_body[:imageAlias] = subject_config[:image_alias]
|
37
37
|
expected_body[:imagePassword] = subject_config[:image_password]
|
38
38
|
|
39
39
|
expect(subject).to receive(:puts).with("ID: #{volume.id}")
|
@@ -52,7 +52,7 @@ describe Chef::Knife::IonoscloudVolumeCreate do
|
|
52
52
|
{
|
53
53
|
method: 'POST',
|
54
54
|
path: "/datacenters/#{subject_config[:datacenter_id]}/volumes",
|
55
|
-
operation: :'
|
55
|
+
operation: :'VolumesApi.datacenters_volumes_post',
|
56
56
|
return_type: 'Volume',
|
57
57
|
body: { properties: expected_body },
|
58
58
|
result: volume,
|
@@ -60,7 +60,7 @@ describe Chef::Knife::IonoscloudVolumeCreate do
|
|
60
60
|
{
|
61
61
|
method: 'GET',
|
62
62
|
path: "/datacenters/#{subject_config[:datacenter_id]}/volumes/#{volume.id}",
|
63
|
-
operation: :'
|
63
|
+
operation: :'VolumesApi.datacenters_volumes_find_by_id',
|
64
64
|
return_type: 'Volume',
|
65
65
|
result: volume,
|
66
66
|
},
|
@@ -70,58 +70,6 @@ describe Chef::Knife::IonoscloudVolumeCreate do
|
|
70
70
|
expect { subject.run }.not_to raise_error(Exception)
|
71
71
|
end
|
72
72
|
|
73
|
-
it 'should not call anything when neither image not image-alias is provided' do
|
74
|
-
volume = volume_mock
|
75
|
-
subject_config = {
|
76
|
-
ionoscloud_username: 'email',
|
77
|
-
ionoscloud_password: 'password',
|
78
|
-
cluster_id: 'cluster_id',
|
79
|
-
datacenter_id: 'datacenter_id',
|
80
|
-
name: volume.properties.name,
|
81
|
-
size: volume.properties.size,
|
82
|
-
type: volume.properties.type,
|
83
|
-
bus: volume.properties.bus,
|
84
|
-
availability_zone: volume.properties.availability_zone,
|
85
|
-
image_password: 'K3tTj8G14a3EgKyNeeiY',
|
86
|
-
}
|
87
|
-
|
88
|
-
subject_config.each { |key, value| subject.config[key] = value }
|
89
|
-
expect(subject.ui).to receive(:error).with('Either \'--image\' or \'--image-alias\' parameter must be provided')
|
90
|
-
|
91
|
-
expect(subject.api_client).not_to receive(:wait_for)
|
92
|
-
expect(subject.api_client).not_to receive(:call_api)
|
93
|
-
|
94
|
-
expect { subject.run }.to raise_error(SystemExit) do |error|
|
95
|
-
expect(error.status).to eq(1)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should not call anything when neither image not image-alias is provided' do
|
100
|
-
volume = volume_mock
|
101
|
-
subject_config = {
|
102
|
-
ionoscloud_username: 'email',
|
103
|
-
ionoscloud_password: 'password',
|
104
|
-
cluster_id: 'cluster_id',
|
105
|
-
datacenter_id: 'datacenter_id',
|
106
|
-
name: volume.properties.name,
|
107
|
-
size: volume.properties.size,
|
108
|
-
type: volume.properties.type,
|
109
|
-
bus: volume.properties.bus,
|
110
|
-
availability_zone: volume.properties.availability_zone,
|
111
|
-
image_alias: 'debian:latest',
|
112
|
-
}
|
113
|
-
|
114
|
-
subject_config.each { |key, value| subject.config[key] = value }
|
115
|
-
expect(subject.ui).to receive(:error).with('Either \'--image-password\' or \'--ssh-keys\' parameter must be provided')
|
116
|
-
|
117
|
-
expect(subject.api_client).not_to receive(:wait_for)
|
118
|
-
expect(subject.api_client).not_to receive(:call_api)
|
119
|
-
|
120
|
-
expect { subject.run }.to raise_error(SystemExit) do |error|
|
121
|
-
expect(error.status).to eq(1)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
73
|
it 'should not make any call if any required option is missing' do
|
126
74
|
required_options = subject.instance_variable_get(:@required_options)
|
127
75
|
|