profitbricks-sdk-ruby 3.0.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/server_spec.rb CHANGED
@@ -15,12 +15,14 @@ describe ProfitBricks::Server do
15
15
  @volume.wait_for { ready? }
16
16
  @volume.attach(@server.id)
17
17
 
18
- @image = ProfitBricks::Image.list[0]
18
+ @image = get_test_image('CDROM')
19
+
19
20
  @server.attach_cdrom(@image.id)
21
+ @server.wait_for { ready? }
20
22
 
21
23
  @composite_server = ProfitBricks::Server.create(
22
- @datacenter.id,
23
- options[:composite_server]
24
+ @datacenter.id,
25
+ options[:composite_server]
24
26
  )
25
27
  end
26
28
 
@@ -36,11 +38,16 @@ describe ProfitBricks::Server do
36
38
  it '#create' do
37
39
  expect(@server.type).to eq('server')
38
40
  expect(@server.id).to match(options[:uuid])
39
- expect(@server.properties['name']).to eq('New Server')
41
+ expect(@server.properties['name']).to eq('Ruby SDK Test')
40
42
  expect(@server.properties['cores']).to eq(1)
41
43
  expect(@server.properties['ram']).to eq(1024)
42
- expect(@server.properties['availabilityZone']).to eq('AUTO')
44
+ expect(@server.properties['availabilityZone']).to eq('ZONE_1')
43
45
  expect(@server.properties['vmState']).to eq('SHUTOFF').or eq('RUNNING')
46
+ expect(@server.properties['cpuFamily']).to eq('INTEL_XEON')
47
+ end
48
+
49
+ it '#create failure' do
50
+ expect { ProfitBricks::Server.create(@datacenter.id, options[:bad_server]) }.to raise_error(Excon::Error::UnprocessableEntity)
44
51
  end
45
52
 
46
53
  it '#create composite' do
@@ -48,10 +55,10 @@ describe ProfitBricks::Server do
48
55
  @composite_server.reload
49
56
  expect(@composite_server.type).to eq('server')
50
57
  expect(@composite_server.id).to match(options[:uuid])
51
- expect(@composite_server.properties['name']).to eq('New Composite Server')
58
+ expect(@composite_server.properties['name']).to eq('Ruby SDK Test Composite')
52
59
  expect(@composite_server.properties['cores']).to eq(1)
53
60
  expect(@composite_server.properties['ram']).to eq(1024)
54
- expect(@composite_server.properties['availabilityZone']).to eq('AUTO')
61
+ expect(@composite_server.properties['availabilityZone']).to eq('ZONE_1')
55
62
  expect(@composite_server.properties['vmState']).to eq('RUNNING')
56
63
  expect(@composite_server.entities['volumes']['items'].count).to be > 0
57
64
  expect(@composite_server.entities['nics']['items'].count).to be > 0
@@ -66,7 +73,7 @@ describe ProfitBricks::Server do
66
73
  # expect(servers[0].properties['name']).to eq('New Server')
67
74
  expect(servers[0].properties['cores']).to eq(1)
68
75
  expect(servers[0].properties['ram']).to eq(1024)
69
- expect(servers[0].properties['availabilityZone']).to eq('AUTO')
76
+ expect(servers[0].properties['availabilityZone']).to eq('ZONE_1')
70
77
  expect(servers[0].properties['vmState']).to eq('RUNNING')
71
78
  expect(servers[0].properties['bootVolume']['type']).to eq('volume')
72
79
  expect(servers[0].properties['bootVolume']['id']).to match(options[:uuid])
@@ -78,27 +85,32 @@ describe ProfitBricks::Server do
78
85
 
79
86
  expect(server.type).to eq('server')
80
87
  expect(server.id).to eq(@server.id)
81
- expect(server.properties['name']).to eq('New Server')
88
+ expect(server.properties['name']).to eq('Ruby SDK Test')
82
89
  expect(server.properties['cores']).to eq(1)
83
90
  expect(server.properties['ram']).to eq(1024)
84
- expect(server.properties['availabilityZone']).to eq('AUTO')
91
+ expect(server.properties['availabilityZone']).to eq('ZONE_1')
85
92
  expect(server.properties['vmState']).to eq('RUNNING')
86
93
  expect(server.properties['bootVolume']['type']).to eq('volume')
87
94
  expect(server.properties['bootVolume']['id']).to match(options[:uuid])
95
+ expect(server.properties['bootVolume']['id']).to eq(@volume.id)
88
96
  expect(server.properties['bootCdrom']).to be nil
97
+ expect(server.properties['cpuFamily']).to eq('INTEL_XEON')
98
+ end
99
+
100
+ it '#get failure' do
101
+ expect { ProfitBricks::Server.get(@datacenter.id,options[:bad_id]) }.to raise_error(Excon::Error::NotFound)
89
102
  end
90
103
 
91
104
  it '#update' do
92
105
  server = @server.update(
93
- name: 'New Server - Updated',
94
- cores: 2
106
+ name: 'Ruby SDK Test RENAME',
95
107
  )
96
108
 
97
109
  expect(server.id).to eq(@server.id)
98
- expect(server.properties['name']).to eq('New Server - Updated')
99
- expect(server.properties['cores']).to eq(2)
110
+ expect(server.properties['name']).to eq('Ruby SDK Test RENAME')
111
+ expect(server.properties['cores']).to eq(1)
100
112
  expect(server.properties['ram']).to eq(1024)
101
- expect(server.properties['availabilityZone']).to eq('AUTO')
113
+ expect(server.properties['availabilityZone']).to eq('ZONE_1')
102
114
  expect(server.properties['vmState']).to eq('RUNNING')
103
115
  expect(server.properties['bootVolume']['type']).to eq('volume')
104
116
  expect(server.properties['bootVolume']['id']).to match(options[:uuid])
@@ -127,7 +139,7 @@ describe ProfitBricks::Server do
127
139
 
128
140
  expect(volumes.count).to be > 0
129
141
  expect(volumes[0].type).to eq('volume')
130
- expect(volumes[0].properties['name']).to eq('my boot volume for server 1')
142
+ expect(volumes[0].properties['name']).to eq('Ruby SDK Test')
131
143
  expect(volumes[0].properties['size']).to be_kind_of(Integer)
132
144
  expect(volumes[0].properties['bus']).to eq('VIRTIO')
133
145
  end
@@ -136,8 +148,11 @@ describe ProfitBricks::Server do
136
148
  volume = @server.get_volume(@volume.id)
137
149
 
138
150
  expect(volume.type).to eq('volume')
139
- expect(volume.properties['name']).to eq('my boot volume for server 1')
151
+ expect(volume.properties['name']).to eq('Ruby SDK Test')
140
152
  expect(volume.properties['size']).to be_kind_of(Integer)
153
+ expect(volume.properties['size']).to eq(2)
154
+ expect(volume.properties['type']).to eq('HDD')
155
+ expect(volume.properties['licenceType']).to eq('UNKNOWN')
141
156
  expect(volume.properties['bus']).to eq('VIRTIO')
142
157
  end
143
158
 
@@ -145,8 +160,11 @@ describe ProfitBricks::Server do
145
160
  volume = @server.attach_volume(@volume.id)
146
161
 
147
162
  expect(volume.type).to eq('volume')
148
- expect(volume.properties['name']).to eq('my boot volume for server 1')
163
+ expect(volume.properties['name']).to eq('Ruby SDK Test')
149
164
  expect(volume.properties['size']).to be_kind_of(Integer)
165
+ expect(volume.properties['size']).to eq(2)
166
+ expect(volume.properties['type']).to eq('HDD')
167
+ expect(volume.properties['licenceType']).to eq('UNKNOWN')
150
168
  expect(volume.properties['bus']).to eq('VIRTIO')
151
169
  end
152
170
 
@@ -156,49 +174,51 @@ describe ProfitBricks::Server do
156
174
  expect(volume).to be_kind_of(Hash)
157
175
  end
158
176
 
159
- #it '#list_cdroms' do
160
- # cdroms = @server.list_cdroms
177
+ it '#list_cdroms' do
178
+ cdroms = @server.list_cdroms
161
179
 
162
- # expect(cdroms.count).to be > 0
163
- # expect(cdroms[0].type).to eq('image')
164
- # expect(cdroms[0].properties['name']).to eq('Ubuntu 14.04')
165
- # expect(cdroms[0].properties['description']).to eq('Ubuntu image description')
166
- # expect(cdroms[0].properties['size']).to be_kind_of(Integer)
167
- #end
180
+ expect(cdroms.count).to be > 0
181
+ expect(cdroms[0].type).to eq('image')
182
+ expect(cdroms[0].properties['name']).to eq(@image.properties['name'])
183
+ expect(cdroms[0].properties['size']).to be_kind_of(Float)
184
+ end
168
185
 
169
- #it '#get_cdrom' do
170
- # cdrom = @server.get_cdrom(@image.id)
186
+ it '#get_cdrom' do
187
+ cdrom = @server.get_cdrom(@image.id)
171
188
 
172
- # expect(cdrom.type).to eq('image')
173
- # expect(cdrom.properties['name']).to eq('Ubuntu 14.04')
174
- # expect(cdrom.properties['description']).to eq('Ubuntu image description')
175
- # expect(cdrom.properties['size']).to be_kind_of(Integer)
176
- #end
189
+ expect(cdrom.type).to eq('image')
190
+ expect(cdrom.properties['name']).to eq(@image.properties['name'])
191
+ expect(cdrom.properties['size']).to be_kind_of(Float)
192
+ end
177
193
 
178
- #it '#attach_cdrom, detach_cdrom' do
179
- # # Detach existing image
180
- # expect(@server.detach_cdrom(@image.id)).to be true
194
+ it '#attach_cdrom, detach_cdrom' do
195
+ # Detach existing image
196
+ @server.detach_cdrom(@image.id)
197
+ @server.wait_for { ready? }
198
+
199
+ # Attach image
200
+ image = @server.attach_cdrom(@image.id)
201
+ @server.wait_for { ready? }
181
202
 
182
- # # Attach image
183
- # image = @server.attach_cdrom(@image.id)
203
+ expect(image.type).to eq('image')
204
+ expect(image.properties['name']).to be_kind_of(String)
205
+ expect(image.properties['size']).to be_kind_of(Float)
206
+ end
184
207
 
185
- # expect(image.type).to eq('image')
186
- # expect(image.properties['name']).to be_kind_of(String)
187
- # # expect(image.properties['description']).to eq('Ubuntu image description')
188
- # expect(image.properties['size']).to be_kind_of(Integer)
189
- #end
208
+ it '#detach_cdrom' do
209
+ @server.attach_cdrom(@image.id)
210
+ @server.wait_for { ready? }
190
211
 
191
- # it '#detach_cdrom' do
192
- # @server.attach_cdrom(@image.id)
193
- # cdrom = @server.detach_cdrom(@image.id)
212
+ cdrom = @server.detach_cdrom(@image.id)
213
+ @server.wait_for { ready? }
194
214
 
195
- # expect(cdrom).to be true
196
- # end
215
+ expect(cdrom).to be_kind_of(Hash)
216
+ end
197
217
 
198
218
  it '#create_nic' do
199
219
  expect(@nic.type).to eq('nic')
200
220
  expect(@nic.id).to match(options[:uuid])
201
- expect(@nic.properties['name']).to eq('nic1')
221
+ expect(@nic.properties['name']).to eq('Ruby SDK Test')
202
222
  expect(@nic.properties['ips']).to be_kind_of(Array)
203
223
  expect(@nic.properties['dhcp']).to be true
204
224
  expect(@nic.properties['lan']).to eq(1)
@@ -210,7 +230,7 @@ describe ProfitBricks::Server do
210
230
  expect(nics.count).to be > 0
211
231
  expect(nics[0].type).to eq('nic')
212
232
  expect(nics[0].id).to match(options[:uuid])
213
- expect(nics[0].properties['name']).to eq('nic1')
233
+ expect(nics[0].properties['name']).to eq('Ruby SDK Test')
214
234
  expect(nics[0].properties['ips']).to be_kind_of(Array)
215
235
  expect(nics[0].properties['dhcp']).to be true
216
236
  expect(nics[0].properties['lan']).to eq(1)
@@ -221,7 +241,7 @@ describe ProfitBricks::Server do
221
241
 
222
242
  expect(nic.type).to eq('nic')
223
243
  expect(nic.id).to match(options[:uuid])
224
- expect(nic.properties['name']).to eq('nic1')
244
+ expect(nic.properties['name']).to eq('Ruby SDK Test')
225
245
  expect(nic.properties['ips']).to be_kind_of(Array)
226
246
  expect(nic.properties['dhcp']).to be true
227
247
  expect(nic.properties['lan']).to eq(1)
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe ProfitBricks::Share do
4
+ before(:all) do
5
+
6
+ @datacenter = ProfitBricks::Datacenter.create(options[:datacenter])
7
+ @datacenter.wait_for { ready? }
8
+
9
+ @group = ProfitBricks::Group.create(options[:group])
10
+ @group.wait_for { ready? }
11
+
12
+ share = options[:share]
13
+ share[:resource_id] = @datacenter.id
14
+ @share = ProfitBricks::Share.create(@group.id,share)
15
+ @share.wait_for { ready? }
16
+ end
17
+
18
+ after(:all) do
19
+ @group.delete()
20
+ @datacenter.delete
21
+ end
22
+
23
+ it '#create failure' do
24
+ share = {}
25
+ share[:resource_id]= @datacenter.id
26
+ expect { ProfitBricks::Share.create(@group.id,share) }.to raise_error(Excon::Error::UnprocessableEntity)
27
+ end
28
+
29
+ it '#create' do
30
+ expect(@share.type).to eq('resource')
31
+ # expect(@share.properties[:editPrivilege]).to be true
32
+ # expect(@share.properties[:sharePrivilege]).to be true
33
+ end
34
+
35
+ it '#list' do
36
+ shares = ProfitBricks::Share.list(@group.id)
37
+
38
+ expect(shares.count).to be > 0
39
+ expect(shares[0].type).to eq('resource')
40
+ end
41
+
42
+ it '#get' do
43
+ share = ProfitBricks::Share.get(@group.id,@datacenter.id)
44
+ expect(share.id).to match(options[:uuid])
45
+ expect(share.type).to eq('resource')
46
+ # expect(share.properties[:editPrivilege]).to be true
47
+ # expect(share.properties[:sharePrivilege]).to be true
48
+ end
49
+
50
+ it '#get failure' do
51
+ expect { ProfitBricks::Share.get(@group.id,options[:bad_id]) }.to raise_error(Excon::Error::NotFound)
52
+ end
53
+
54
+ it '#update' do
55
+ share = ProfitBricks::Share.update(@group.id,@datacenter.id,{
56
+ edit_privilege: false
57
+ })
58
+
59
+ expect(share.type).to eq('resource')
60
+ # expect(share.properties[:editPrivilege]).to be false
61
+ end
62
+
63
+ it '#delete' do
64
+ expect(ProfitBricks::Share.delete(@group.id,@datacenter.id)).to be true
65
+ end
66
+ end
@@ -19,8 +19,8 @@ describe ProfitBricks::Snapshot do
19
19
  it '#create' do
20
20
  expect(@snapshot.type).to eq('snapshot')
21
21
  expect(@snapshot.id).to match(options[:uuid])
22
- expect(@snapshot.properties['name']).to eq('Snapshot of storage X on 12.12.12 12:12:12 - updated')
23
- expect(@snapshot.properties['description']).to eq('description of a snapshot - updated')
22
+ expect(@snapshot.properties['name']).to eq('Ruby SDK Test')
23
+ expect(@snapshot.properties['description']).to eq('Ruby SDK test snapshot')
24
24
  expect(@snapshot.properties['location']).to match(/\w+\/\w+/)
25
25
  expect(@snapshot.properties['size']).to be nil
26
26
  expect(@snapshot.properties['cpuHotPlug']).to be false
@@ -36,6 +36,10 @@ describe ProfitBricks::Snapshot do
36
36
  expect(@snapshot.properties['licenceType']).to be nil
37
37
  end
38
38
 
39
+ # it '#create failure' do
40
+ # expect { ProfitBricks::Snapshot.create(@datacenter.id, @volume.id, description: 'Ruby SDK test snapshot - RENAME') }.to raise_error(Excon::Error::UnprocessableEntity, /Attribute 'name' is required/)
41
+ # end
42
+
39
43
  it '#list' do
40
44
  snapshots = ProfitBricks::Snapshot.list
41
45
 
@@ -64,6 +68,7 @@ describe ProfitBricks::Snapshot do
64
68
 
65
69
  expect(snapshot.type).to eq('snapshot')
66
70
  expect(snapshot.id).to eq(@snapshot.id)
71
+ expect(snapshot.properties['location']).to eq('us/las')
67
72
  expect(snapshot.properties['name']).to be_kind_of(String)
68
73
  expect(snapshot.properties['description']).to be_kind_of(String)
69
74
  expect(snapshot.properties['location']).to match(/\w+\/\w+/)
@@ -79,15 +84,33 @@ describe ProfitBricks::Snapshot do
79
84
  expect(snapshot.properties['discScsiHotPlug']).to be false
80
85
  expect(snapshot.properties['discScsiHotUnplug']).to be false
81
86
  expect(snapshot.properties['licenceType']).to eq('UNKNOWN')
87
+
88
+ expect(snapshot.properties['size']).to eq(@volume.properties['size'])
89
+ expect(snapshot.properties['cpuHotPlug']).to eq(@volume.properties['cpuHotPlug'])
90
+ expect(snapshot.properties['cpuHotUnplug']).to eq(@volume.properties['cpuHotUnplug'])
91
+ expect(snapshot.properties['ramHotPlug']).to eq(@volume.properties['ramHotPlug'])
92
+ expect(snapshot.properties['ramHotUnplug']).to eq(@volume.properties['ramHotUnplug'])
93
+ expect(snapshot.properties['nicHotPlug']).to eq(@volume.properties['nicHotPlug'])
94
+ expect(snapshot.properties['nicHotUnplug']).to eq(@volume.properties['nicHotUnplug'])
95
+ expect(snapshot.properties['discVirtioHotPlug']).to eq(@volume.properties['discVirtioHotPlug'])
96
+ expect(snapshot.properties['discVirtioHotUnplug']).to eq(@volume.properties['discVirtioHotUnplug'])
97
+ expect(snapshot.properties['discScsiHotPlug']).to eq(@volume.properties['discScsiHotPlug'])
98
+ expect(snapshot.properties['discScsiHotUnplug']).to eq(@volume.properties['discScsiHotUnplug'])
99
+ expect(snapshot.properties['licenceType']).to eq(@volume.properties['licenceType'])
100
+ end
101
+
102
+ it '#get failure' do
103
+ expect { ProfitBricks::Snapshot.get(options[:bad_id]) }.to raise_error(Excon::Error::NotFound, /Resource does not exist/)
82
104
  end
83
105
 
84
106
  it '#update' do
85
- snapshot = @snapshot.update(name: 'New name')
107
+ snapshot = @snapshot.update({ name: 'Ruby SDK Test - RENAME', description: 'Ruby SDK test snapshot - RENAME' })
86
108
  snapshot.wait_for { ready? }
87
109
 
88
110
  expect(snapshot.type).to eq('snapshot')
89
111
  expect(snapshot.id).to match(options[:uuid])
90
- expect(snapshot.properties['name']).to eq('New name')
112
+ expect(snapshot.properties['name']).to eq('Ruby SDK Test - RENAME')
113
+ expect(snapshot.properties['description']).to eq('Ruby SDK test snapshot - RENAME')
91
114
  expect(snapshot.properties['description']).to be_kind_of(String)
92
115
  expect(snapshot.properties['location']).to match(/\w+\/\w+/)
93
116
  expect(snapshot.properties['size']).to be_kind_of(Integer)
data/spec/spec_helper.rb CHANGED
@@ -9,7 +9,7 @@ RSpec.configure do |config|
9
9
  end
10
10
 
11
11
  ProfitBricks.configure do |config|
12
- config.url = 'https://api.profitbricks.com/cloudapi/v3/'
12
+ config.url = 'https://api.profitbricks.com/cloudapi/v4/'
13
13
  config.username = ENV['PROFITBRICKS_USERNAME']
14
14
  config.password = ENV['PROFITBRICKS_PASSWORD']
15
15
  config.debug = false
@@ -2,95 +2,232 @@ module Helpers
2
2
  def options
3
3
  {
4
4
  uuid: /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i,
5
- datacenter: {
6
- name: 'Ruby SDK Datacenter',
7
- description: 'SDK test environment',
8
- location: 'de/fkb'
9
- },
10
-
11
- server: {
12
- name: 'New Server',
13
- ram: 1024,
14
- cores: 1
15
- },
16
-
17
- volume: {
18
- name: 'my boot volume for server 1',
19
- size: 5,
20
- type: 'HDD',
21
- licenceType: 'UNKNOWN',
22
- availabilityZone: 'AUTO'
23
- },
24
-
25
- snapshot: {
26
- name: 'Snapshot of storage X on 12.12.12 12:12:12 - updated',
27
- description: 'description of a snapshot - updated'
28
- },
29
-
30
- nic: {
31
- name: 'nic1',
32
- dhcp: true,
33
- lan: 1,
34
- firewallActive: true,
35
- nat: false
36
- },
37
-
38
- fwrule: {
39
- name: 'SSH',
40
- protocol: 'TCP',
41
- sourceMac: '01:23:45:67:89:00',
42
- sourceIp: nil,
43
- targetIp: nil,
44
- portRangeStart: 22,
45
- portRangeEnd: 22,
46
- icmpType: nil,
47
- icmpCode: nil
48
- },
49
-
50
- loadbalancer: {
51
- name: 'My LB',
52
- # ip: '10.2.2.3',
53
- dhcp: 'true'
54
- },
55
-
56
- lan: {
57
- name: 'public Lan 4',
58
- public: 'true'
59
- },
60
-
61
- ipblock: {
62
- location: "de/fra",
63
- size: 1
64
- },
65
-
66
- composite_server: {
67
- name: 'New Composite Server',
68
- ram: 1024,
69
- cores: 1,
70
- volumes: [
71
- {
72
- name: 'composite-boot',
5
+ mac_addres: /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/,
6
+ datacenter: {
7
+ name: 'Ruby SDK Test',
8
+ description: 'Ruby SDK test datacenter',
9
+ location: 'us/las'
10
+ },
11
+ bad_datacenter: {
12
+ name: 'Ruby SDK Datacenter',
13
+ },
14
+
15
+ datacenter_composite: {
16
+ name: 'Ruby SDK Test Composite',
17
+ description: 'Ruby SDK test composite datacenter',
18
+ location: 'us/las',
19
+ servers: [
20
+ {
21
+ name: 'Ruby SDK Test',
22
+ ram: 1024,
23
+ cores: 1
24
+ }
25
+ ],
26
+ volumes: [
27
+ {
28
+ name: 'Ruby SDK Test',
29
+ size: 2,
30
+ bus: 'VIRTIO',
31
+ type: 'HDD',
32
+ licenceType: 'UNKNOWN',
33
+ availabilityZone: 'ZONE_3'
34
+ }
35
+ ]
36
+ },
37
+
38
+ bad_id: '00000000-0000-0000-0000-000000000000',
39
+
40
+ server: {
41
+ name: 'Ruby SDK Test',
42
+ ram: 1024,
43
+ cores: 1,
44
+ availabilityZone: 'ZONE_1',
45
+ cpuFamily: 'INTEL_XEON'
46
+ },
47
+
48
+ bad_server: {
49
+ name: 'New Server',
50
+ ram: 1024,
51
+ },
52
+
53
+ volume: {
54
+ name: 'Ruby SDK Test',
55
+ size: 2,
56
+ type: 'HDD',
57
+ licenceType: 'UNKNOWN',
58
+ availabilityZone: 'ZONE_3',
59
+ bus: 'VIRTIO'
60
+ },
61
+
62
+ volume_with_alias: {
63
+ name: 'volume created with alias',
64
+ imagePassword: 'Vol44lias',
73
65
  size: 5,
74
66
  type: 'HDD',
75
- licenceType: 'UNKNOWN'
76
- }
77
- ],
78
- nics: [
79
- {
80
- name: 'nic1',
81
- dhcp: 'true',
67
+ availabilityZone: 'AUTO',
68
+ imageAlias: 'ubuntu:latest'
69
+ },
70
+
71
+ bad_volume: {
72
+ name: 'bad volume to test failure ',
73
+ size: 0,
74
+ type: 'ABC',
75
+ licenceType: 'UNKNOWN',
76
+ availabilityZone: 'AUTO'
77
+ },
78
+
79
+ snapshot: {
80
+ name: 'Ruby SDK Test',
81
+ description: 'Ruby SDK test snapshot'
82
+ },
83
+
84
+ bad_snapshot: {
85
+ description: 'description of a snapshot - updated'
86
+ },
87
+
88
+
89
+ nic: {
90
+ name: 'Ruby SDK Test',
91
+ dhcp: true,
82
92
  lan: 1,
83
- firewallrules: [
93
+ firewallActive: true,
94
+ nat: false
95
+ },
96
+
97
+ bad_nic: {
98
+ name: 'nic1',
99
+ dhcp: true,
100
+ firewallActive: true,
101
+ nat: false
102
+ },
103
+
104
+ fwrule: {
105
+ name: 'SSH',
106
+ protocol: 'TCP',
107
+ sourceMac: '01:23:45:67:89:00',
108
+ sourceIp: nil,
109
+ targetIp: nil,
110
+ portRangeStart: 22,
111
+ portRangeEnd: 22,
112
+ icmpType: nil,
113
+ icmpCode: nil
114
+ },
115
+
116
+ bad_fwrule: {
117
+ name: 'SSH',
118
+ sourceMac: '01:23:45:67:89:00',
119
+ sourceIp: nil,
120
+ targetIp: nil,
121
+ portRangeStart: 22,
122
+ portRangeEnd: 22,
123
+ icmpType: nil,
124
+ icmpCode: nil
125
+ },
126
+
127
+ loadbalancer: {
128
+ name: 'Ruby SDK Test',
129
+ # ip: '10.2.2.3',
130
+ dhcp: 'true'
131
+ },
132
+
133
+ bad_loadbalancer: {
134
+ # ip: '10.2.2.3',
135
+ #dhcp: 'true'
136
+ },
137
+
138
+ lan: {
139
+ name: 'Ruby SDK Test',
140
+ public: 'true'
141
+ },
142
+
143
+ bad_lan: {
144
+ public: 'true'
145
+ },
146
+
147
+ ipblock: {
148
+ name: 'Ruby SDK Test',
149
+ location: 'us/las',
150
+ size: 2
151
+ },
152
+
153
+ ipblock_failover: {
154
+ location: 'us/las',
155
+ size: 1
156
+ },
157
+
158
+ composite_server: {
159
+ name: 'Ruby SDK Test Composite',
160
+ ram: 1024,
161
+ cores: 1,
162
+ availabilityZone: 'ZONE_1',
163
+ volumes: [
164
+ {
165
+ name: 'Ruby SDK Test',
166
+ size: 2,
167
+ type: 'HDD',
168
+ licenceType: 'UNKNOWN',
169
+ bus: 'VIRTIO',
170
+ availabilityZone: 'ZONE_3'
171
+ }
172
+ ],
173
+ nics: [
84
174
  {
85
- name: 'SSH',
86
- protocol: 'TCP',
87
- portRangeStart: 22,
88
- portRangeEnd: 22,
175
+ name: 'Ruby SDK Test',
176
+ dhcp: 'true',
177
+ lan: 1,
178
+ firewallActive: true,
179
+ nat: false,
180
+ firewallrules: [
181
+ {
182
+ name: 'SSH',
183
+ protocol: 'TCP',
184
+ portRangeStart: 22,
185
+ portRangeEnd: 22,
186
+ sourceMac: '01:23:45:67:89:00'
187
+ }
188
+ ]
89
189
  }
90
190
  ]
91
- }
92
- ]
93
- }
191
+ },
192
+ group: {
193
+ name: 'Ruby SDK Test',
194
+ #create_datacenter: 'true',
195
+ #create_snapshot: 'true',
196
+ #reserve_ip: 'true',
197
+ #access_activity_log: 'true'
198
+ },
199
+ bad_group: {
200
+ #create_datacenter: 'true'
201
+ },
202
+ share: {
203
+ resource_id: '',
204
+ edit_privilege: 'true',
205
+ share_privilege: 'true'
206
+ },
207
+ user: {
208
+ firstname: 'John',
209
+ lastname: 'Doe',
210
+ email: 'no-reply@example.com',
211
+ password: 'secretpassword123',
212
+ administrator: 'true',
213
+ # force_sec_auth: 'false'
214
+ },
215
+ bad_user: {
216
+ firstname: 'Jane',
217
+ lastname: 'Doe'
218
+ }
94
219
  }
95
220
  end
221
+
222
+ def get_test_image(image_type)
223
+ test_location = 'us/las'
224
+ images = ProfitBricks::Image.list
225
+ minImage = nil
226
+ images.each do |image|
227
+ if image.metadata['state'] == 'AVAILABLE' && image.properties['public'] == true && image.properties['imageType'] == image_type && image.properties['location'] == test_location && image.properties['licenceType'] == 'LINUX' && (minImage.nil? || minImage.properties.size > image.properties.size)
228
+ minImage = image
229
+ end
230
+ end
231
+ minImage
232
+ end
96
233
  end