leaseweb-rest-api 1.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.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +201 -0
- data/leaseweb-rest-api.gemspec +17 -0
- data/lib/hash-to-uri-conversion.rb +32 -0
- data/lib/leaseweb-rest-api.rb +280 -0
- data/readme.md +111 -0
- data/spec/lib/leaseweb-rest-api_spec.rb +643 -0
- data/spec/spec_helper.rb +18 -0
- metadata +95 -0
data/readme.md
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
leaseweb-rest-api
|
2
|
+
=====================
|
3
|
+
|
4
|
+
Rubygem to talk to Leaseweb's API
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'leaseweb-rest-api'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
```
|
17
|
+
$ bundle
|
18
|
+
```
|
19
|
+
|
20
|
+
Or install it yourself:
|
21
|
+
|
22
|
+
```
|
23
|
+
$ gem install leaseweb-rest-api
|
24
|
+
```
|
25
|
+
|
26
|
+
## Generating a public/private keypair
|
27
|
+
|
28
|
+
Make sure you add a strong password to your SSH key!
|
29
|
+
|
30
|
+
```
|
31
|
+
ssh-keygen -t rsa -b 4096 -C "test@example.com" -f id_rsa
|
32
|
+
openssl rsa -in id_rsa -pubout > id_rsa.pub.pem
|
33
|
+
rm id_rsa.pub
|
34
|
+
```
|
35
|
+
|
36
|
+
Copy the content of id_rsa.pub.pem to the 'Public RSA Key'-field your [SSC API page](https://secure.leaseweb.nl/en/sscApi). Click 'Show API key' for your API key. Keep your id_rsa file private.
|
37
|
+
|
38
|
+
## Usage
|
39
|
+
|
40
|
+
Start by creating a new instance of the `LeasewebAPI` class, and passing your api key, private key and private key password.
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
api_key = 'e12b534e-3bf6-4208-89e6-e43798b3c30f'
|
44
|
+
privateKeyFile = './id_rsa'
|
45
|
+
password = 'my_super_strong_s3cr3t_passw0rd'
|
46
|
+
api = LeasewebAPI.new(api_key, privateKeyFile, password)
|
47
|
+
```
|
48
|
+
|
49
|
+
All return values are the direct JSON responses from Leaseweb converted into a Hash.
|
50
|
+
|
51
|
+
See: [documentation](http://developer.leaseweb.com/document/api-documentation/)
|
52
|
+
|
53
|
+
### Managing servers
|
54
|
+
|
55
|
+
List my baremetal servers:
|
56
|
+
|
57
|
+
```
|
58
|
+
servers = api.getBareMetals()
|
59
|
+
```
|
60
|
+
|
61
|
+
List all operating systems:
|
62
|
+
|
63
|
+
```
|
64
|
+
api.getOperatingSystems
|
65
|
+
```
|
66
|
+
|
67
|
+
Install a server:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
params = []
|
71
|
+
params << { "type" => "ext2", "size" => 500, "mountpoint" => "/boot" }
|
72
|
+
params << { "type" => "swap", "size" => 4096 }
|
73
|
+
params << { "type" => "ext4", "size" => 2048, "mountpoint" => "/tmp" }
|
74
|
+
params << { "type" => "ext4", "size" => "*", "mountpoint" => "/" }
|
75
|
+
|
76
|
+
hdd = { "disk" => "/dev/sda", "params" => params, "bootable" => 0 }
|
77
|
+
|
78
|
+
puts api.installServer(serverid, osid, hdd)
|
79
|
+
```
|
80
|
+
|
81
|
+
Check the status of the install:
|
82
|
+
|
83
|
+
```
|
84
|
+
puts api.getInstallationStatus(bareMetalId)
|
85
|
+
```
|
86
|
+
|
87
|
+
Reboot a server:
|
88
|
+
|
89
|
+
```
|
90
|
+
puts api.postReboot(bareMetalId)
|
91
|
+
```
|
92
|
+
|
93
|
+
Set iPXE lease:
|
94
|
+
|
95
|
+
```
|
96
|
+
puts api.setLease(bareMetalId, 'http://pxe.example.com/boot.ipxe')
|
97
|
+
```
|
98
|
+
|
99
|
+
List all my domains:
|
100
|
+
|
101
|
+
```
|
102
|
+
puts api.getDomains
|
103
|
+
```
|
104
|
+
|
105
|
+
## Contribute
|
106
|
+
|
107
|
+
1. Fork it
|
108
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
109
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
110
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
111
|
+
5. Create new Pull Request
|
@@ -0,0 +1,643 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/leaseweb-rest-api'
|
3
|
+
|
4
|
+
describe LeasewebAPI do
|
5
|
+
let(:apikey) { 'e17b534d-3af6-4208-89e6-e43798b3c30f' }
|
6
|
+
let(:privateKey) { '/Users/a.vermeer/Documents/leaseweb-rest-api/id_rsa' }
|
7
|
+
let(:password) { 'cdcHRt+,zVuZWtV2a7PkixZTn' }
|
8
|
+
let(:request_headers) do
|
9
|
+
{ 'X-Lsw-Auth' => apikey }
|
10
|
+
end
|
11
|
+
|
12
|
+
subject { LeasewebAPI.new(apikey, privateKey, password) }
|
13
|
+
|
14
|
+
describe '#getDomains' do
|
15
|
+
let(:response) { "{}" }
|
16
|
+
|
17
|
+
it 'returns a list of all the domains assigned to the account' do
|
18
|
+
stub_request(:get, "https://api.leaseweb.com/v1/domains").
|
19
|
+
with(:headers => request_headers).
|
20
|
+
to_return(:status => 200, :body => response, :headers => {})
|
21
|
+
|
22
|
+
subject.getDomains
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#getDomain' do
|
27
|
+
let(:response) { "{}" }
|
28
|
+
|
29
|
+
it 'returns a representation of a domain resource' do
|
30
|
+
stub_request(:get, "https://api.leaseweb.com/v1/domains/example.com").
|
31
|
+
with(:headers => request_headers).
|
32
|
+
to_return(:status => 200, :body => response, :headers => {})
|
33
|
+
|
34
|
+
subject.getDomain('example.com')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#updateDomain' do
|
39
|
+
let(:response) { "{}" }
|
40
|
+
|
41
|
+
it 'updates a domain' do
|
42
|
+
body = 'ttl=86400'
|
43
|
+
|
44
|
+
stub_request(:put, "https://api.leaseweb.com/v1/domains/example.com").
|
45
|
+
with(:headers => request_headers, :body => body).
|
46
|
+
to_return(:status => 200, :body => response, :headers => {})
|
47
|
+
|
48
|
+
subject.updateDomain('example.com', 86400)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#getDNSRecords' do
|
53
|
+
let(:response) { "{}" }
|
54
|
+
|
55
|
+
it 'returns a representation of a specific dnsRecords of a domain' do
|
56
|
+
stub_request(:get, "https://api.leaseweb.com/v1/domains/example.com/dnsRecords").
|
57
|
+
with(:headers => request_headers).
|
58
|
+
to_return(:status => 200, :body => response, :headers => {})
|
59
|
+
|
60
|
+
subject.getDNSRecords('example.com')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#createDNSRecords' do
|
65
|
+
let(:response) { "{}" }
|
66
|
+
|
67
|
+
it 'creates a new dns record' do
|
68
|
+
body = 'host=example.com&content=123.123.123.123&type=MX&priority=10'
|
69
|
+
|
70
|
+
stub_request(:post, "https://api.leaseweb.com/v1/domains/example.com/dnsRecords").
|
71
|
+
with(:headers => request_headers, :body => body).
|
72
|
+
to_return(:status => 200, :body => response, :headers => {})
|
73
|
+
|
74
|
+
subject.createDNSRecords('example.com', 'example.com', '123.123.123.123', 'MX', 10)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#getDNSRecord' do
|
79
|
+
let(:response) { "{}" }
|
80
|
+
|
81
|
+
it 'returns a representation of a specific dnsRecord of a domain' do
|
82
|
+
stub_request(:get, "https://api.leaseweb.com/v1/domains/example.com/dnsRecords/123").
|
83
|
+
with(:headers => request_headers).
|
84
|
+
to_return(:status => 200, :body => response, :headers => {})
|
85
|
+
|
86
|
+
subject.getDNSRecord('example.com', 123)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#updateDNSRecord' do
|
91
|
+
let(:response) { "{}" }
|
92
|
+
|
93
|
+
it 'updates a dns record' do
|
94
|
+
body = 'id=123&host=example.com&content=10.10.10.10&type=MX&priority=20'
|
95
|
+
|
96
|
+
stub_request(:put, "https://api.leaseweb.com/v1/domains/example.com/dnsRecords/123").
|
97
|
+
with(:headers => request_headers, :body => body).
|
98
|
+
to_return(:status => 200, :body => response, :headers => {})
|
99
|
+
|
100
|
+
subject.updateDNSRecord('example.com', '123', 'example.com', '10.10.10.10', 'MX', '20')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '#deleteDNSRecord' do
|
105
|
+
let(:response) { "{}" }
|
106
|
+
|
107
|
+
it 'deletes a dns record for a domain' do
|
108
|
+
stub_request(:delete, "https://api.leaseweb.com/v1/domains/example.com/dnsRecords/123").
|
109
|
+
with(:headers => request_headers).
|
110
|
+
to_return(:status => 200, :body => response, :headers => {})
|
111
|
+
|
112
|
+
subject.deleteDNSRecord('example.com', '123')
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe '#getRescueImages' do
|
117
|
+
let(:response) do
|
118
|
+
"{\"rescueImages\":[{\"rescueImage\":{\"id\":121,\"name\":\"FreeBSD Rescue 2.1 (amd64)\"}},{\"rescueImage\":{\"id\":122,\"name\":\"FreeBSD Rescue 2.1 (x86)\"}},{\"rescueImage\":{\"id\":137,\"name\":\"Rescue 2.1 (amd64)\"}},{\"rescueImage\":{\"id\":138,\"name\":\"Rescue 2.1 (x86)\"}}]}"
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'returns all your available rescue images' do
|
122
|
+
stub_request(:get, "https://api.leaseweb.com/v1/rescueImages").
|
123
|
+
with(:headers => request_headers).
|
124
|
+
to_return(:status => 200, :body => response, :headers => {})
|
125
|
+
|
126
|
+
subject.getRescueImages
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '#getBareMetals' do
|
131
|
+
let(:response) do
|
132
|
+
"{\"bareMetals\":[{\"bareMetal\":{\"reference\":null,\"bareMetalId\":\"114916\",\"serverName\":\"LSPG003\",\"serverType\":\"Bare Metal\"}},{\"bareMetal\":{\"reference\":null,\"bareMetalId\":\"198969\",\"serverName\":\"LSPG001\",\"serverType\":\"Bare Metal\"}},{\"bareMetal\":{\"reference\":null,\"bareMetalId\":\"198970\",\"serverName\":\"LSPG002\",\"serverType\":\"Bare Metal\"}}]}"
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'returns the id of all your Bare Metal servers' do
|
136
|
+
stub_request(:get, "https://api.leaseweb.com/v1/bareMetals").
|
137
|
+
with(:headers => request_headers).
|
138
|
+
to_return(:status => 200, :body => response, :headers => {})
|
139
|
+
|
140
|
+
subject.getBareMetals
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe '#getBareMetal' do
|
145
|
+
let(:response) do
|
146
|
+
"{\"bareMetal\":{\"reference\":null,\"location\":{\"site\":\"SFO-12\",\"cabinet\":\"0209\",\"rackspace\":\"-\",\"combinationLock\":\"-\"},\"server\":{\"ram\":\"16GB\",\"kvm\":\"No\",\"serverType\":\"Preinstalled SFO12.300.0209 DL120 G7\",\"processorType\":\"Intel Quad-Core Xeon E3-1230\",\"processorSpeed\":\"3200 Mhz\",\"numberOfCpus\":1,\"numberOfCores\":4,\"hardDisks\":\" 2x1TB \",\"hardwareRaid\":\"No\"},\"network\":{\"dataPack\":\"Connectivity - see other packs\",\"ipsFreeOfCharge\":\"1\",\"ipsAssigned\":1,\"excessIpsPrice\":\"0.00\",\"dataPackExcess\":{\"type\":\"\",\"value\":\"0.00\",\"unit\":\"\"},\"macAddresses\":{\"mac\":[\"C8:CB:B8:C5:17:0C\",\"C8:CB:B8:C5:17:0D\"]}},\"extras\":{\"extra\":{\"service\":\"Private network: 100Mbps\"}},\"bareMetalId\":\"114916\",\"serverName\":\"LSPG003\",\"serverType\":\"Bare Metal\",\"serverHostingPack\":{\"reference\":null,\"bareMetalId\":\"114916\",\"serverName\":\"LSPG003\",\"serverType\":\"Bare Metal\",\"startDate\":\"Jul 1, 2012\",\"endDate\":\"\",\"contractTerm\":\"3 month(s)\"},\"serverSpecifications\":[],\"serviceLevelAgreement\":{\"sla\":\"Basic - 24x7x24\"},\"datacenterAccessCards\":{\"accessCards\":[\"0\",[]]}}}"
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'returns the data of your Bare Metal server' do
|
150
|
+
stub_request(:get, "https://api.leaseweb.com/v1/bareMetals/114916").
|
151
|
+
with(:headers => request_headers).
|
152
|
+
to_return(:status => 200, :body => response, :headers => {})
|
153
|
+
|
154
|
+
subject.getBareMetal(114916)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe '#updateBareMetal' do
|
159
|
+
let(:response) { "{}" }
|
160
|
+
|
161
|
+
it 'updates a bareMetal' do
|
162
|
+
body = 'reference=test'
|
163
|
+
|
164
|
+
stub_request(:put, "https://api.leaseweb.com/v1/bareMetals/114916").
|
165
|
+
with(:headers => request_headers, :body => body).
|
166
|
+
to_return(:status => 200, :body => response, :headers => {})
|
167
|
+
|
168
|
+
subject.updateBareMetal(114916, 'test')
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe '#getSwitchPort' do
|
173
|
+
let(:response) do
|
174
|
+
"{\"switchPort\":{\"status\":\"open\",\"serverId\":\"114916\",\"serverName\":\"LSPG003\",\"switchNode\":1}}"
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'returns the switchport status of your Bare Metal server' do
|
178
|
+
stub_request(:get, "https://api.leaseweb.com/v1/bareMetals/114916/switchPort").
|
179
|
+
with(:headers => request_headers).
|
180
|
+
to_return(:status => 200, :body => response, :headers => {})
|
181
|
+
|
182
|
+
subject.getSwitchPort(114916)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe '#postSwitchPortOpen' do
|
187
|
+
let(:response) { "{}" }
|
188
|
+
|
189
|
+
it 'opens the switch port of your Bare Metal server' do
|
190
|
+
stub_request(:post, "https://api.leaseweb.com/v1/bareMetals/114916/switchPort/open").
|
191
|
+
with(:headers => request_headers).
|
192
|
+
to_return(:status => 200, :body => response, :headers => {})
|
193
|
+
|
194
|
+
subject.postSwitchPortOpen(114916)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
describe '#postSwitchPortClose' do
|
199
|
+
let(:response) { "{}" }
|
200
|
+
|
201
|
+
it 'closes the switch port of your Bare Metal server' do
|
202
|
+
stub_request(:post, "https://api.leaseweb.com/v1/bareMetals/114916/switchPort/close").
|
203
|
+
with(:headers => request_headers).
|
204
|
+
to_return(:status => 200, :body => response, :headers => {})
|
205
|
+
|
206
|
+
subject.postSwitchPortClose(114916)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
describe '#getPowerStatus' do
|
211
|
+
let(:response) do
|
212
|
+
"{\"powerStatus\":{\"status\":\"on\",\"serverId\":\"114916\",\"serverName\":\"LSPG003\"}}"
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'returns the power status of your Bare Metal server' do
|
216
|
+
stub_request(:get, "https://api.leaseweb.com/v1/bareMetals/114916/powerStatus").
|
217
|
+
with(:headers => request_headers).
|
218
|
+
to_return(:status => 200, :body => response, :headers => {})
|
219
|
+
|
220
|
+
subject.getPowerStatus(114916)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe '#getIPs' do
|
225
|
+
let(:response) do
|
226
|
+
"{\"ips\":[{\"ip\":{\"ip\":\"209.58.131.10\",\"reverseLookup\":\"\",\"ipDetails\":{\"gateway\":\"209.58.131.62\",\"mask\":\"255.255.255.192\"},\"nullRouted\":false,\"billingInformation\":{\"price\":\"0.00\",\"startDate\":\"Jun 1, 2015\",\"endDate\":null},\"serverId\":\"114916\",\"serverType\":\"Bare Metal\",\"serverName\":\"LSPG003\"}}]}"
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'returns the ips of your Bare Metal server' do
|
230
|
+
stub_request(:get, "https://api.leaseweb.com/v1/bareMetals/114916/ips").
|
231
|
+
with(:headers => request_headers).
|
232
|
+
to_return(:status => 200, :body => response, :headers => {})
|
233
|
+
|
234
|
+
subject.getIPs(114916)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
describe '#getIP' do
|
239
|
+
let(:response) do
|
240
|
+
"{\"ip\":{\"ip\":\"209.58.131.10\",\"reverseLookup\":\"\",\"ipDetails\":{\"gateway\":\"209.58.131.62\",\"mask\":\"255.255.255.192\"},\"nullRouted\":false,\"billingInformation\":{\"price\":\"0.00\",\"startDate\":\"Jun 1, 2015\",\"endDate\":null},\"serverId\":\"114916\",\"serverType\":\"Bare Metal\",\"serverName\":\"LSPG003\"}}"
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'returns information about the ip of your Bare Metal server' do
|
244
|
+
stub_request(:get, "https://api.leaseweb.com/v1/bareMetals/114916/ips/209.58.131.10").
|
245
|
+
with(:headers => request_headers).
|
246
|
+
to_return(:status => 200, :body => response, :headers => {})
|
247
|
+
|
248
|
+
subject.getIP(114916, "209.58.131.10")
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
describe '#updateIP' do
|
253
|
+
let(:response) { "{}" }
|
254
|
+
|
255
|
+
it 'updates information of the ip of your Bare Metal server' do
|
256
|
+
stub_request(:put, "https://api.leaseweb.com/v1/bareMetals/114916/ips/209.58.131.10").
|
257
|
+
with(:headers => request_headers).
|
258
|
+
to_return(:status => 200, :body => response, :headers => {})
|
259
|
+
|
260
|
+
subject.updateIP(114916, "209.58.131.10", 'modified-by-api.leaseweb.com', 1)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
describe '#getNetworkUsage' do
|
265
|
+
let(:response) do
|
266
|
+
"{\"bandwidth\":{\"measurement\":{\"node\":{\"in\":\"-\",\"out\":\"-\",\"total\":\"10.91 Kbps\"},\"total\":\"10.91 Kbps\",\"average\":\"10.91 Kbps\"},\"overusage\":\"0 bps\",\"serverId\":114916,\"serverName\":\"LSPG003\",\"interval\":{\"from\":\"09-05-2015\",\"to\":\"08-06-2015\"},\"monthlyThreshold\":\"0 Mbps\"},\"dataTraffic\":{\"measurement\":{\"node\":{\"in\":\"3.5 GB\",\"out\":\"523.81 MB\",\"total\":\"4.02 GB\"},\"total\":\"4.02 GB\"},\"overusage\":\"0 B\",\"serverId\":114916,\"serverName\":\"LSPG003\",\"interval\":{\"from\":\"09-05-2015\",\"to\":\"08-06-2015\"},\"monthlyThreshold\":\"0 GB\"}}"
|
267
|
+
end
|
268
|
+
|
269
|
+
it 'returns network usage details of a bareMetal server' do
|
270
|
+
stub_request(:get, "https://api.leaseweb.com/v1/bareMetals/114916/networkUsage").
|
271
|
+
with(:headers => request_headers).
|
272
|
+
to_return(:status => 200, :body => response, :headers => {})
|
273
|
+
|
274
|
+
subject.getNetworkUsage(114916)
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
describe '#getNetworkUsageBandWidth' do
|
279
|
+
let(:response) do
|
280
|
+
"{\"bandwidth\":{\"measurement\":{\"node\":{\"in\":\"-\",\"out\":\"-\",\"total\":\"10.91 Kbps\"},\"total\":\"10.91 Kbps\",\"average\":\"10.91 Kbps\"},\"overusage\":\"0 bps\",\"serverId\":114916,\"serverName\":\"LSPG003\",\"interval\":{\"from\":\"09-05-2015\",\"to\":\"08-06-2015\"},\"monthlyThreshold\":\"0 Mbps\"},\"dataTraffic\":{\"measurement\":{\"node\":{\"in\":\"3.5 GB\",\"out\":\"523.81 MB\",\"total\":\"4.02 GB\"},\"total\":\"4.02 GB\"},\"overusage\":\"0 B\",\"serverId\":114916,\"serverName\":\"LSPG003\",\"interval\":{\"from\":\"09-05-2015\",\"to\":\"08-06-2015\"},\"monthlyThreshold\":\"0 GB\"}}"
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'returns network usage details of a bareMetal server' do
|
284
|
+
stub_request(:get, "https://api.leaseweb.com/v1/bareMetals/114916/networkUsage/bandWidth?dateFrom=06-04-2015&dateTo=06-05-2015").
|
285
|
+
with(:headers => request_headers).
|
286
|
+
to_return(:status => 200, :body => response, :headers => {})
|
287
|
+
|
288
|
+
subject.getNetworkUsageBandWidth(114916, '06-04-2015', '06-05-2015', 'json')
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
describe '#getNetworkUsageDataTraffic' do
|
293
|
+
let(:response) do
|
294
|
+
"{\"dataTraffic\":{\"measurement\":{\"node\":{\"in\":\"370.71 MB\",\"out\":\"98.07 MB\",\"total\":\"468.78 MB\"},\"total\":\"468.78 MB\"},\"overusage\":\"0 B\",\"serverId\":198969,\"serverName\":\"LSPG001\",\"interval\":{\"from\":\"06-04-2015\",\"to\":\"06-05-2015\"},\"monthlyThreshold\":\"0 GB\"}}"
|
295
|
+
end
|
296
|
+
|
297
|
+
it 'returns network usage details of a bareMetal server' do
|
298
|
+
stub_request(:get, "https://api.leaseweb.com/v1/bareMetals/114916/networkUsage/dataTraffic?dateFrom=06-04-2015&dateTo=06-05-2015").
|
299
|
+
with(:headers => request_headers).
|
300
|
+
to_return(:status => 200, :body => response, :headers => {})
|
301
|
+
|
302
|
+
subject.getNetworkUsageDataTraffic(114916, '06-04-2015', '06-05-2015', 'json')
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
describe '#postReboot' do
|
307
|
+
let(:response) { "{}" }
|
308
|
+
|
309
|
+
it 'performs a reboot of the server' do
|
310
|
+
stub_request(:post, "https://api.leaseweb.com/v1/bareMetals/114916/reboot").
|
311
|
+
with(:headers => request_headers).
|
312
|
+
to_return(:status => 200, :body => response, :headers => {})
|
313
|
+
|
314
|
+
subject.postReboot(114916)
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
describe '#installServer' do
|
319
|
+
let(:response) { "{}" }
|
320
|
+
|
321
|
+
it 'performs a re-installation of the server' do
|
322
|
+
body = 'osId=1899'
|
323
|
+
|
324
|
+
stub_request(:post, "https://api.leaseweb.com/v1/bareMetals/114916/install").
|
325
|
+
with(:headers => request_headers, :body => body).
|
326
|
+
to_return(:status => 200, :body => response, :headers => {})
|
327
|
+
|
328
|
+
subject.installServer(114916, 1899)
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
describe '#postResqueMode' do
|
333
|
+
let(:response) { "{}" }
|
334
|
+
|
335
|
+
it 'Launches the rescue mode for this bare metal server' do
|
336
|
+
body = 'osId=121'
|
337
|
+
|
338
|
+
stub_request(:post, "https://api.leaseweb.com/v1/bareMetals/114916/rescueMode").
|
339
|
+
with(:headers => request_headers, :body => body).
|
340
|
+
to_return(:status => 200, :body => response, :headers => {})
|
341
|
+
|
342
|
+
subject.postResqueMode(114916, 121)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
describe '#getRootPassword' do
|
347
|
+
let(:response) do
|
348
|
+
"{\"dataTraffic\":{\"measurement\":{\"node\":{\"in\":\"370.71 MB\",\"out\":\"98.07 MB\",\"total\":\"468.78 MB\"},\"total\":\"468.78 MB\"},\"overusage\":\"0 B\",\"serverId\":198969,\"serverName\":\"LSPG001\",\"interval\":{\"from\":\"06-04-2015\",\"to\":\"06-05-2015\"},\"monthlyThreshold\":\"0 GB\"}}"
|
349
|
+
end
|
350
|
+
|
351
|
+
it 'returns the root password of the server' do
|
352
|
+
stub_request(:get, "https://api.leaseweb.com/v1/bareMetals/114916/rootPassword").
|
353
|
+
with(:headers => request_headers).
|
354
|
+
to_return(:status => 200, :body => response, :headers => {})
|
355
|
+
|
356
|
+
subject.getRootPassword(114916, 'json')
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
describe '#getInstallationStatus' do
|
361
|
+
let(:response) do
|
362
|
+
"{\"installationStatus\":{\"code\":1000,\"description\":\"Installing\",\"serverPackId\":\"114916\",\"serverName\":\"LSPG003\"}}"
|
363
|
+
end
|
364
|
+
|
365
|
+
it 'returns the installation status of the server' do
|
366
|
+
stub_request(:get, "https://api.leaseweb.com/v1/bareMetals/114916/installationStatus").
|
367
|
+
with(:headers => request_headers).
|
368
|
+
to_return(:status => 200, :body => response, :headers => {})
|
369
|
+
|
370
|
+
subject.getInstallationStatus(114916)
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
describe '#getLeases' do
|
375
|
+
let(:response) do
|
376
|
+
"{\"_metadata\":{\"totalCount\":1,\"limit\":10,\"offset\":0},\"leases\":[{\"ip\":\"209.58.131.10\",\"pop\":\"SFO-12\",\"mac\":\"C8:CB:B8:C5:17:0C\",\"scope\":\"209.58.131.0\",\"options\":[{\"name\":\"Bootfile Name\",\"optionId\":\"67\",\"policyName\":null,\"type\":\"String\",\"userClass\":\"\",\"value\":\"undionly.kpxe\",\"vendorClass\":\"\"},{\"name\":\"DNS Servers\",\"optionId\":\"6\",\"policyName\":null,\"type\":\"IPv4Address\",\"userClass\":\"\",\"value\":\"209.58.128.22,209.58.135.185\",\"vendorClass\":\"\"},{\"name\":\"Boot Server Host Name\",\"optionId\":\"66\",\"policyName\":null,\"type\":\"String\",\"userClass\":\"\",\"value\":\"209.58.128.13\",\"vendorClass\":\"\"},{\"name\":\"Bootfile Name\",\"optionId\":\"67\",\"policyName\":null,\"type\":\"String\",\"userClass\":\"gPXE\",\"value\":\"http:\\/\\/95.211.51.8\\/server\\/getPxeConfig\\/serverId\\/58898\\/key\\/86504289080a3a914ac53912ea55336f\",\"vendorClass\":\"\"}]}]}"
|
377
|
+
end
|
378
|
+
|
379
|
+
it 'returns a list of DHCP Leases for every MAC Address for a given bare metal' do
|
380
|
+
stub_request(:get, "https://api.leaseweb.com/v1/bareMetals/114916/leases").
|
381
|
+
with(:headers => request_headers).
|
382
|
+
to_return(:status => 200, :body => response, :headers => {})
|
383
|
+
|
384
|
+
subject.getLeases(114916)
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
describe '#setLease' do
|
389
|
+
let(:response) { "{}" }
|
390
|
+
|
391
|
+
it 'Creates a new DHCP lease' do
|
392
|
+
stub_request(:post, "https://api.leaseweb.com/v1/bareMetals/114916/leases").
|
393
|
+
with(:headers => request_headers).
|
394
|
+
to_return(:status => 200, :body => response, :headers => {})
|
395
|
+
|
396
|
+
subject.setLease(114916, "http://example.com/boot.ipxe")
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
describe '#getLease' do
|
401
|
+
let(:response) do
|
402
|
+
"{\"ip\":\"209.58.131.10\",\"pop\":\"SFO-12\",\"mac\":\"C8:CB:B8:C5:17:0C\",\"scope\":\"209.58.131.0\",\"options\":[{\"name\":\"Bootfile Name\",\"optionId\":\"67\",\"policyName\":null,\"type\":\"String\",\"userClass\":\"\",\"value\":\"undionly.kpxe\",\"vendorClass\":\"\"},{\"name\":\"DNS Servers\",\"optionId\":\"6\",\"policyName\":null,\"type\":\"IPv4Address\",\"userClass\":\"\",\"value\":\"209.58.128.22,209.58.135.185\",\"vendorClass\":\"\"},{\"name\":\"Boot Server Host Name\",\"optionId\":\"66\",\"policyName\":null,\"type\":\"String\",\"userClass\":\"\",\"value\":\"209.58.128.13\",\"vendorClass\":\"\"},{\"name\":\"Bootfile Name\",\"optionId\":\"67\",\"policyName\":null,\"type\":\"String\",\"userClass\":\"gPXE\",\"value\":\"http:\\/\\/95.211.51.8\\/server\\/getPxeConfig\\/serverId\\/58898\\/key\\/86504289080a3a914ac53912ea55336f\",\"vendorClass\":\"\"}]}"
|
403
|
+
end
|
404
|
+
|
405
|
+
it 'returns a DHCP Lease for every MAC Address for a bare metal with specific MAC address' do
|
406
|
+
stub_request(:get, "https://api.leaseweb.com/v1/bareMetals/114916/leases/C8:CB:B8:C5:17:0C").
|
407
|
+
with(:headers => request_headers).
|
408
|
+
to_return(:status => 200, :body => response, :headers => {})
|
409
|
+
|
410
|
+
subject.getLease(114916, "C8:CB:B8:C5:17:0C")
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
describe '#deleteLease' do
|
415
|
+
let(:response) { "{}" }
|
416
|
+
|
417
|
+
it 'deletes a DHCP lease for a specific mac address' do
|
418
|
+
stub_request(:delete, "https://api.leaseweb.com/v1/bareMetals/114916/leases/C8:CB:B8:C5:17:0C").
|
419
|
+
with(:headers => request_headers).
|
420
|
+
to_return(:status => 200, :body => response, :headers => {})
|
421
|
+
|
422
|
+
subject.deleteLease(114916, "C8:CB:B8:C5:17:0C")
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
describe '#getPrivateNetworks' do
|
427
|
+
let(:response) do
|
428
|
+
"{\"meta\":{\"first_page\":1,\"last_page\":1,\"previous_page\":null,\"current_page\":1,\"next_page\":null,\"total_results\":1,\"results_per_page\":50},\"results\":[{\"id\":157,\"name\":\"\"}]}"
|
429
|
+
end
|
430
|
+
|
431
|
+
it 'returns a list of all your privatenetworks' do
|
432
|
+
stub_request(:get, "https://api.leaseweb.com/v1/privateNetworks").
|
433
|
+
with(:headers => request_headers).
|
434
|
+
to_return(:status => 200, :body => response, :headers => {})
|
435
|
+
|
436
|
+
subject.getPrivateNetworks
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
describe '#createPrivateNetworks' do
|
441
|
+
let(:response) { "{}" }
|
442
|
+
|
443
|
+
it 'Creates a new private network' do
|
444
|
+
stub_request(:post, "https://api.leaseweb.com/v1/privateNetworks").
|
445
|
+
with(:headers => request_headers).
|
446
|
+
to_return(:status => 200, :body => response, :headers => {})
|
447
|
+
|
448
|
+
subject.createPrivateNetworks
|
449
|
+
end
|
450
|
+
end
|
451
|
+
|
452
|
+
describe '#getPrivateNetworks' do
|
453
|
+
let(:response) do
|
454
|
+
"{\"meta\":{\"first_page\":1,\"last_page\":1,\"previous_page\":null,\"current_page\":1,\"next_page\":null,\"total_results\":1,\"results_per_page\":50},\"results\":[{\"id\":157,\"name\":\"\"}]}"
|
455
|
+
end
|
456
|
+
|
457
|
+
it 'returns a list of all your privatenetworks' do
|
458
|
+
stub_request(:get, "https://api.leaseweb.com/v1/privateNetworks").
|
459
|
+
with(:headers => request_headers).
|
460
|
+
to_return(:status => 200, :body => response, :headers => {})
|
461
|
+
|
462
|
+
subject.getPrivateNetworks
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
466
|
+
describe '#getPrivateNetwork' do
|
467
|
+
let(:response) do
|
468
|
+
"{\"id\":157,\"name\":\"\",\"bareMetals\":[{\"id\":198969,\"status\":\"CONFIGURED\",\"dataCenter\":\"SFO-12\",\"CIDR\":\"10.29.0.32\\/27\",\"broadcast\":\"10.29.0.63\",\"gateway\":\"10.29.0.62\",\"netmask\":\"255.255.255.224\",\"portSpeed\":100},{\"id\":198970,\"status\":\"CONFIGURED\",\"dataCenter\":\"SFO-12\",\"CIDR\":\"10.29.0.32\\/27\",\"broadcast\":\"10.29.0.63\",\"gateway\":\"10.29.0.62\",\"netmask\":\"255.255.255.224\",\"portSpeed\":100},{\"id\":114916,\"status\":\"CONFIGURED\",\"dataCenter\":\"SFO-12\",\"CIDR\":\"10.29.0.32\\/27\",\"broadcast\":\"10.29.0.63\",\"gateway\":\"10.29.0.62\",\"netmask\":\"255.255.255.224\",\"portSpeed\":100}]}"
|
469
|
+
end
|
470
|
+
|
471
|
+
it 'returns information about your private network and servers' do
|
472
|
+
stub_request(:get, "https://api.leaseweb.com/v1/privateNetworks/157").
|
473
|
+
with(:headers => request_headers).
|
474
|
+
to_return(:status => 200, :body => response, :headers => {})
|
475
|
+
|
476
|
+
subject.getPrivateNetwork(157)
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
480
|
+
describe '#updatePrivateNetwork' do
|
481
|
+
let(:response) { "{}" }
|
482
|
+
|
483
|
+
it 'updates the name of your private network' do
|
484
|
+
body = 'name=test'
|
485
|
+
|
486
|
+
stub_request(:put, "https://api.leaseweb.com/v1/privateNetworks/157").
|
487
|
+
with(:headers => request_headers, :body => body).
|
488
|
+
to_return(:status => 200, :body => response, :headers => {})
|
489
|
+
|
490
|
+
subject.updatePrivateNetwork(157, 'test')
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
describe '#deletePrivateNetwork' do
|
495
|
+
let(:response) { "{}" }
|
496
|
+
|
497
|
+
it 'deletes a private network' do
|
498
|
+
stub_request(:delete, "https://api.leaseweb.com/v1/privateNetworks/157").
|
499
|
+
with(:headers => request_headers).
|
500
|
+
to_return(:status => 200, :body => response, :headers => {})
|
501
|
+
|
502
|
+
subject.deletePrivateNetwork(157)
|
503
|
+
end
|
504
|
+
end
|
505
|
+
|
506
|
+
describe '#createPrivateNetworks' do
|
507
|
+
let(:response) { "{}" }
|
508
|
+
|
509
|
+
it 'add a server to your private network' do
|
510
|
+
body = 'bareMetalId=114916'
|
511
|
+
|
512
|
+
stub_request(:post, "https://api.leaseweb.com/v1/privateNetworks/157/bareMetals").
|
513
|
+
with(:headers => request_headers, :body => body).
|
514
|
+
to_return(:status => 200, :body => response, :headers => {})
|
515
|
+
|
516
|
+
subject.createPrivateNetworksBareMetals(157, 114916)
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
describe '#deletePrivateNetworksBareMetals' do
|
521
|
+
let(:response) { "{}" }
|
522
|
+
|
523
|
+
it 'delete server from your private network' do
|
524
|
+
stub_request(:delete, "https://api.leaseweb.com/v1/privateNetworks/157/bareMetals/114916").
|
525
|
+
with(:headers => request_headers).
|
526
|
+
to_return(:status => 200, :body => response, :headers => {})
|
527
|
+
|
528
|
+
subject.deletePrivateNetworksBareMetals(157, 114916)
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
describe '#getOperatingSystems' do
|
533
|
+
let(:response) do
|
534
|
+
"{\"operatingSystems\":[{\"operatingSystem\":{\"id\":664,\"name\":\"CentOS 5 (i386)\"}},{\"operatingSystem\":{\"id\":665,\"name\":\"CentOS 5 (x86_64)\"}},{\"operatingSystem\":{\"id\":867,\"name\":\"CentOS 6 (i386)\"}},{\"operatingSystem\":{\"id\":868,\"name\":\"CentOS 6 (x86_64)\"}},{\"operatingSystem\":{\"id\":1899,\"name\":\"CentOS 7 (x86_64)\"}},{\"operatingSystem\":{\"id\":921,\"name\":\"CloudLinux 6.4 (i386)\"}},{\"operatingSystem\":{\"id\":920,\"name\":\"CloudLinux 6.4 (x86_64)\"}},{\"operatingSystem\":{\"id\":532,\"name\":\"Debian 6.0 (amd64)\"}},{\"operatingSystem\":{\"id\":531,\"name\":\"Debian 6.0 (x86)\"}},{\"operatingSystem\":{\"id\":1566,\"name\":\"Debian 7.0 (x86)\"}},{\"operatingSystem\":{\"id\":1567,\"name\":\"Debian 7.0 (x86_64)\"}},{\"operatingSystem\":{\"id\":2142,\"name\":\"Debian 8.0 (x86_64)\"}},{\"operatingSystem\":{\"id\":873,\"name\":\"ESXi 5.0 (x86_64)\"}},{\"operatingSystem\":{\"id\":1039,\"name\":\"ESXi 5.1 (x86_64)\"}},{\"operatingSystem\":{\"id\":1864,\"name\":\"ESXi 5.5 (x86_64)\"}},{\"operatingSystem\":{\"id\":2143,\"name\":\"ESXi 6.0 (x86_64)\"}},{\"operatingSystem\":{\"id\":1953,\"name\":\"FreeBSD 10.1 (amd64)\"}},{\"operatingSystem\":{\"id\":1901,\"name\":\"FreeBSD 10.1 (i386)\"}},{\"operatingSystem\":{\"id\":764,\"name\":\"FreeBSD 8.4 (amd64)\"}},{\"operatingSystem\":{\"id\":765,\"name\":\"FreeBSD 8.4 (x86)\"}},{\"operatingSystem\":{\"id\":927,\"name\":\"FreeBSD 9.3 (amd64)\"}},{\"operatingSystem\":{\"id\":926,\"name\":\"FreeBSD 9.3 (i386)\"}},{\"operatingSystem\":{\"id\":946,\"name\":\"Ubuntu 12.04 (amd64)\"}},{\"operatingSystem\":{\"id\":945,\"name\":\"Ubuntu 12.04 (x86)\"}},{\"operatingSystem\":{\"id\":1789,\"name\":\"Ubuntu 14.04 (amd64)\"}},{\"operatingSystem\":{\"id\":1790,\"name\":\"Ubuntu 14.04 (x86)\"}},{\"operatingSystem\":{\"id\":672,\"name\":\"Windows 2008 R2 Enterprise (x64)\"}},{\"operatingSystem\":{\"id\":175,\"name\":\"Windows 2008 R2 Standard (x64)\"}},{\"operatingSystem\":{\"id\":539,\"name\":\"Windows 2008 R2 Standard (2 CPU) (x64)\"}},{\"operatingSystem\":{\"id\":165,\"name\":\"Windows 2008 R2 Web (x64)\"}},{\"operatingSystem\":{\"id\":538,\"name\":\"Windows 2008 R2 Web (2 CPU) (x64)\"}},{\"operatingSystem\":{\"id\":1610,\"name\":\"Windows Server 2012 Datacenter (1 CPU) (x64)\"}},{\"operatingSystem\":{\"id\":1611,\"name\":\"Windows Server 2012 Datacenter (2 CPU) (x64)\"}},{\"operatingSystem\":{\"id\":2002,\"name\":\"Windows Server 2012 R2 Datacenter (1 CPU) (x64)\"}},{\"operatingSystem\":{\"id\":2003,\"name\":\"Windows Server 2012 R2 Datacenter (2 CPU) (x64)\"}},{\"operatingSystem\":{\"id\":2000,\"name\":\"Windows Server 2012 R2 Standard (1 CPU) (x64)\"}},{\"operatingSystem\":{\"id\":2001,\"name\":\"Windows Server 2012 R2 Standard (2 CPU) (x64)\"}},{\"operatingSystem\":{\"id\":1603,\"name\":\"Windows Server 2012 Standard (1 CPU) (x64)\"}},{\"operatingSystem\":{\"id\":1604,\"name\":\"Windows Server 2012 Standard (2 CPU) (x64)\"}}]}"
|
535
|
+
end
|
536
|
+
|
537
|
+
it 'returns the list of available operatingSystems for installation' do
|
538
|
+
stub_request(:get, "https://api.leaseweb.com/v1/operatingSystems").
|
539
|
+
with(:headers => request_headers).
|
540
|
+
to_return(:status => 200, :body => response, :headers => {})
|
541
|
+
|
542
|
+
subject.getOperatingSystems
|
543
|
+
end
|
544
|
+
end
|
545
|
+
|
546
|
+
describe '#getOperatingSystem' do
|
547
|
+
let(:response) do
|
548
|
+
"{\"operatingSystem\":{\"id\":1899,\"name\":\"CentOS 7 (x86_64)\"}}"
|
549
|
+
end
|
550
|
+
|
551
|
+
it 'returns the details of an operating system for installation' do
|
552
|
+
stub_request(:get, "https://api.leaseweb.com/v1/operatingSystems/1899").
|
553
|
+
with(:headers => request_headers).
|
554
|
+
to_return(:status => 200, :body => response, :headers => {})
|
555
|
+
|
556
|
+
subject.getOperatingSystem(1899)
|
557
|
+
end
|
558
|
+
end
|
559
|
+
|
560
|
+
describe '#getControlPanels' do
|
561
|
+
let(:response) do
|
562
|
+
"{\"controlPanels\":[{\"controlPanel\":{\"id\":1868,\"name\":\"Plesk 12 (10 Domains Linux)\"}},{\"controlPanel\":{\"id\":1875,\"name\":\"Plesk 12 (30 Domains Linux)\"}},{\"controlPanel\":{\"id\":1878,\"name\":\"Plesk 12 (Unlimited Domains Linux)\"}}]}"
|
563
|
+
end
|
564
|
+
|
565
|
+
it 'returns the details of an operating system for installation' do
|
566
|
+
stub_request(:get, "https://api.leaseweb.com/v1/operatingSystems/1899/controlPanels").
|
567
|
+
with(:headers => request_headers).
|
568
|
+
to_return(:status => 200, :body => response, :headers => {})
|
569
|
+
|
570
|
+
subject.getControlPanels(1899)
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
describe '#getControlPanel' do
|
575
|
+
let(:response) do
|
576
|
+
"{\"controlPanel\":{\"id\":1868,\"name\":\"Plesk 12 (10 Domains Linux)\"}}"
|
577
|
+
end
|
578
|
+
|
579
|
+
it 'returns the details of available control panels for installation on a particular operating system' do
|
580
|
+
stub_request(:get, "https://api.leaseweb.com/v1/operatingSystems/1899/controlPanels/1868").
|
581
|
+
with(:headers => request_headers).
|
582
|
+
to_return(:status => 200, :body => response, :headers => {})
|
583
|
+
|
584
|
+
subject.getControlPanel(1899, 1868)
|
585
|
+
end
|
586
|
+
end
|
587
|
+
|
588
|
+
describe '#getPartitionSchema' do
|
589
|
+
let(:response) do
|
590
|
+
"{\"partitionSchema\":{\"limit\":7,\"disks\":{\"disk\":[\"\\/dev\\/sda\",\"\\/dev\\/hda\",\"\\/dev\\/cciss\\/c0d0\"]},\"suggestion\":{\"disk\":\"\\/dev\\/sda\",\"bootable\":0,\"hdd\":{\"partition\":[{\"index\":0,\"size\":\"500\",\"type\":\"ext2\",\"mountpoint\":\"\\/boot\"},{\"index\":1,\"size\":\"4096\",\"type\":\"swap\",\"mountpoint\":\"\"},{\"index\":2,\"size\":\"2048\",\"type\":\"ext4\",\"mountpoint\":\"\\/tmp\"},{\"index\":3,\"size\":\"*\",\"type\":\"ext4\",\"mountpoint\":\"\\/\"}]}},\"filesystemTypes\":{\"type\":[\"ext2\",\"ext3\",\"ext4\",\"xfs\",\"swap\"]}}}"
|
591
|
+
end
|
592
|
+
|
593
|
+
it 'returns the list of available partition schema\'s for installation' do
|
594
|
+
stub_request(:get, "https://api.leaseweb.com/v1/operatingSystems/1899/partitionSchema?serverPackId=114916").
|
595
|
+
with(:headers => request_headers).
|
596
|
+
to_return(:status => 200, :body => response, :headers => {})
|
597
|
+
|
598
|
+
subject.getPartitionSchema(1899, 114916)
|
599
|
+
end
|
600
|
+
end
|
601
|
+
|
602
|
+
describe '#getIps' do
|
603
|
+
let(:response) do
|
604
|
+
"{\"ips\":[{\"ip\":{\"ip\":\"209.58.131.10\",\"reverseLookup\":\"\",\"ipDetails\":{\"gateway\":\"209.58.131.62\",\"mask\":\"255.255.255.192\"},\"nullRouted\":false,\"billingInformation\":{\"price\":\"0.00\",\"startDate\":\"Jun 1, 2015\",\"endDate\":null},\"serverId\":\"114916\",\"serverType\":\"Bare Metal\",\"serverName\":\"LSPG003\"}},{\"ip\":{\"ip\":\"209.58.128.85\",\"reverseLookup\":\"\",\"ipDetails\":{\"gateway\":\"209.58.128.126\",\"mask\":\"255.255.255.192\"},\"nullRouted\":false,\"billingInformation\":{\"price\":\"0.00\",\"startDate\":\"Mar 1, 2015\",\"endDate\":null},\"serverId\":\"198969\",\"serverType\":\"Bare Metal\",\"serverName\":\"LSPG001\"}},{\"ip\":{\"ip\":\"209.58.128.148\",\"reverseLookup\":\"\",\"ipDetails\":{\"gateway\":\"209.58.128.190\",\"mask\":\"255.255.255.192\"},\"nullRouted\":false,\"billingInformation\":{\"price\":\"0.00\",\"startDate\":\"Mar 1, 2015\",\"endDate\":null},\"serverId\":\"198970\",\"serverType\":\"Bare Metal\",\"serverName\":\"LSPG002\"}}]}"
|
605
|
+
end
|
606
|
+
|
607
|
+
it 'returns all IPs associated to the account' do
|
608
|
+
stub_request(:get, "https://api.leaseweb.com/v1/ips").
|
609
|
+
with(:headers => request_headers).
|
610
|
+
to_return(:status => 200, :body => response, :headers => {})
|
611
|
+
|
612
|
+
subject.getIps
|
613
|
+
end
|
614
|
+
end
|
615
|
+
|
616
|
+
describe '#getIps' do
|
617
|
+
let(:response) do
|
618
|
+
"{\"ip\":{\"ip\":\"209.58.131.10\",\"reverseLookup\":\"\",\"ipDetails\":{\"gateway\":\"209.58.131.62\",\"mask\":\"255.255.255.192\"},\"nullRouted\":false,\"billingInformation\":{\"price\":\"0.00\",\"startDate\":\"Jun 1, 2015\",\"endDate\":null},\"serverId\":\"114916\",\"serverType\":\"Bare Metal\",\"serverName\":\"LSPG003\"}}"
|
619
|
+
end
|
620
|
+
|
621
|
+
it 'returns information about the IP' do
|
622
|
+
stub_request(:get, "https://api.leaseweb.com/v1/ips/209.58.131.10").
|
623
|
+
with(:headers => request_headers).
|
624
|
+
to_return(:status => 200, :body => response, :headers => {})
|
625
|
+
|
626
|
+
subject.getIp('209.58.131.10')
|
627
|
+
end
|
628
|
+
end
|
629
|
+
|
630
|
+
describe '#updateIp' do
|
631
|
+
let(:response) { "{}" }
|
632
|
+
|
633
|
+
it 'Updates information about the IP' do
|
634
|
+
body = 'reverseLookup=modified-by-api.leaseweb.com&nullRouted=1'
|
635
|
+
|
636
|
+
stub_request(:put, "https://api.leaseweb.com/v1/ips/209.58.131.10").
|
637
|
+
with(:headers => request_headers, :body => body).
|
638
|
+
to_return(:status => 200, :body => response, :headers => {})
|
639
|
+
|
640
|
+
subject.updateIp('209.58.131.10', 'modified-by-api.leaseweb.com', 1)
|
641
|
+
end
|
642
|
+
end
|
643
|
+
end
|