fog-softlayer 0.3.6 → 0.3.7
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 +8 -8
- data/.travis.yml +2 -0
- data/CHANGELOG.md +8 -1
- data/CONTRIBUTORS.md +2 -0
- data/README.md +2 -2
- data/examples/compute.md +28 -7
- data/examples/dns.md +3 -2
- data/examples/key_pairs.md +81 -0
- data/examples/network.md +3 -2
- data/examples/storage.md +4 -3
- data/examples/tags.md +4 -3
- data/lib/fog.rb +0 -6
- data/lib/fog/softlayer/compute.rb +16 -8
- data/lib/fog/softlayer/core.rb +6 -4
- data/lib/fog/softlayer/dns.rb +3 -3
- data/lib/fog/softlayer/models/compute/key_pair.rb +48 -0
- data/lib/fog/softlayer/models/compute/key_pairs.rb +37 -0
- data/lib/fog/softlayer/models/compute/server.rb +37 -10
- data/lib/fog/softlayer/requests/compute/create_key_pair.rb +41 -0
- data/lib/fog/softlayer/requests/compute/delete_key_pair.rb +37 -0
- data/lib/fog/softlayer/requests/compute/get_bare_metal_server.rb +1 -1
- data/lib/fog/softlayer/requests/compute/get_bare_metal_servers.rb +1 -1
- data/lib/fog/softlayer/requests/compute/get_key_pair.rb +36 -0
- data/lib/fog/softlayer/requests/compute/get_key_pairs.rb +29 -0
- data/lib/fog/softlayer/requests/compute/get_vm.rb +1 -1
- data/lib/fog/softlayer/requests/compute/get_vms.rb +1 -1
- data/lib/fog/softlayer/requests/compute/update_key_pair.rb +43 -0
- data/lib/fog/softlayer/storage.rb +3 -3
- data/lib/fog/softlayer/version.rb +1 -1
- data/tests/softlayer/compute/schema.rb +11 -0
- data/tests/softlayer/models/compute/key_pair_tests.rb +47 -0
- data/tests/softlayer/models/compute/server_tests.rb +1 -1
- data/tests/softlayer/requests/compute/key_pair_tests.rb +79 -0
- data/tests/softlayer/requests/compute/tag_tests.rb +1 -1
- metadata +11 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTRkYjQxZWNhZTFhMzZhNWE5OWU2NmIyMjQ3ZGVkYzI2MTQ0MGRhZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjkzMWIxMWU2NTVkY2E4N2U4YTE5ZThmZmU4ZWZhNWI1MDQ1MmNiMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmFmY2YyMTc2MzU2NDNhOGM5MDUyMjFhOTVjOWM2ZjQ1YzRhMjRlNzY4ZjI4
|
10
|
+
NDg2NjZkMTJmYTI2OTQxN2Q1OGFmZDU4NGQ4ZjIyZjQ0NDVjYmFhNjA0ZmQy
|
11
|
+
MDMxNTljNmE2Yjg4YjllMWU2ZDM5MWU4NDBlYzkzNzY2YmFhMzk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWIwOTc3N2ZiMGQ4MmYxMWMxOGZiMjllODg0MDk1YmVkNmJlMWQ0MmVhY2I5
|
14
|
+
OTU2Y2ExYzA4MDdiNzMzYTNmMjZjODY1YWRlNzFkNjQzNmE3NDM0NjVkZTIy
|
15
|
+
MjI1MThjZDI3NTFlMjIxODg2ZjQxYjU1OTQ4ZTY5YWVjY2NiZGQ=
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 0.3.7 2014-07-11
|
2
|
+
* Added support for ssh key pairs.
|
3
|
+
* See [key_pairs.md](https://github.com/fog/fog-softlayer/blob/master/examples/key_pairs.md) for details.
|
4
|
+
* Fix [issue 19](https://github.com/fog/fog-softlayer/issues/19) Storage initialization bug.
|
5
|
+
* Fix [issue 17], incompatibility with Rails 4.1.4. *thanks konsti*
|
6
|
+
* Updated .fog file example and datacenter option. *thanks
|
7
|
+
|
1
8
|
## 0.3.2 2014-06-30
|
2
9
|
* No longer requires `fog` gem.
|
3
10
|
|
@@ -10,7 +17,7 @@
|
|
10
17
|
* Tag model.
|
11
18
|
* Added vlan and private_vlan properties to Server model.
|
12
19
|
* Fixed up bare_metal? on Server so it's not a hack. *thanks fernandes*
|
13
|
-
* Fixed Bundler/dep issues with Ruby 1.8.7.
|
20
|
+
* Fixed Bundler/dep issues with Ruby 1.8.7. *thanks fernandes*
|
14
21
|
* Added some missing license headers.
|
15
22
|
* Updated Compute examples and Tag examples to reflect new Network service.
|
16
23
|
* Moved shared logic from `lib/fog/softlayer/compute.rb` to `lib/fog/softlayer/core.rb`
|
data/CONTRIBUTORS.md
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
### `fog-softlayer` - SoftLayer module for fog.
|
2
2
|
[](http://badge.fury.io/rb/fog-softlayer)
|
3
|
-
[](https://travis-ci.org/fog/fog-softlayer)
|
4
|
+
[](https://gemnasium.com/fog/fog-softlayer)
|
5
5
|
|
6
6
|
This gem is a module for the `fog` gem that allows you to manage resources in
|
7
7
|
the SoftLayer Cloud.
|
data/examples/compute.md
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
These examples all assume you have `~/.fog` which contains the following
|
4
4
|
|
5
5
|
```yaml
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
default:
|
7
|
+
softlayer_username: example-username
|
8
|
+
softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
|
9
|
+
softlayer_default_domain: example.com
|
9
10
|
```
|
10
11
|
|
11
12
|
#### Create a connection to SoftLayer Compute Service
|
@@ -127,7 +128,7 @@ These examples all assume you have `~/.fog` which contains the following
|
|
127
128
|
:flavor_id => "m1.small",
|
128
129
|
:image_id => "23f7f05f-3657-4330-8772-329ed2e816bc",
|
129
130
|
:name => "test",
|
130
|
-
:datacenter =>
|
131
|
+
:datacenter => "ams01"
|
131
132
|
}
|
132
133
|
new_server = @sl.servers.create(opts)
|
133
134
|
new_server.id # => 1337
|
@@ -140,7 +141,7 @@ These examples all assume you have `~/.fog` which contains the following
|
|
140
141
|
:flavor_id => "m1.small",
|
141
142
|
:os_code => "UBUNTU_LATEST",
|
142
143
|
:name => "test1",
|
143
|
-
:datacenter =>
|
144
|
+
:datacenter => "ams01",
|
144
145
|
:bare_metal => true
|
145
146
|
}
|
146
147
|
@sl.servers.create(opts)
|
@@ -159,7 +160,7 @@ These examples all assume you have `~/.fog` which contains the following
|
|
159
160
|
:name => "hostname",
|
160
161
|
:os_code => "UBUNTU_LATEST",
|
161
162
|
:name => "test2",
|
162
|
-
:datacenter =>
|
163
|
+
:datacenter => "ams01"
|
163
164
|
}
|
164
165
|
```
|
165
166
|
|
@@ -175,11 +176,31 @@ These examples all assume you have `~/.fog` which contains the following
|
|
175
176
|
:name => "hostname",
|
176
177
|
:os_code => "UBUNTU_LATEST",
|
177
178
|
:name => "test2",
|
178
|
-
:datacenter =>
|
179
|
+
:datacenter => "ams01",
|
179
180
|
:bare_metal => true
|
180
181
|
}
|
181
182
|
```
|
182
183
|
|
184
|
+
1. Create a server with one or more key pairs (also see [key_pairs.md](./key_pairs.md) )
|
185
|
+
|
186
|
+
```ruby
|
187
|
+
the_first_key = @sl.key_pairs.by_label('my-new-key')
|
188
|
+
# => <Fog::Compute::Softlayer::KeyPair>
|
189
|
+
the_second_key = @sl.key_pairs.by_label('my-other-new-key')
|
190
|
+
# => <Fog::Compute::Softlayer::KeyPair>
|
191
|
+
|
192
|
+
opts = {
|
193
|
+
:flavor_id => 'm1.small',
|
194
|
+
:os_code => 'UBUNTU_LATEST',
|
195
|
+
:datacenter => 'hkg02',
|
196
|
+
:name => 'cphrmky',
|
197
|
+
:key_pairs => [ the_first_key, the_second_key ]
|
198
|
+
}
|
199
|
+
@sl.servers.create(opts)
|
200
|
+
# => <Fog::Compute::Softlayer::Server>
|
201
|
+
```
|
202
|
+
|
203
|
+
|
183
204
|
1. Delete a VM or Bare Metal instance.
|
184
205
|
|
185
206
|
```ruby
|
data/examples/dns.md
CHANGED
@@ -4,8 +4,9 @@ These examples all assume you have `~/.fog` which contains the following
|
|
4
4
|
|
5
5
|
|
6
6
|
```yaml
|
7
|
-
|
8
|
-
|
7
|
+
default:
|
8
|
+
softlayer_username: example-username
|
9
|
+
softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
|
9
10
|
```
|
10
11
|
|
11
12
|
#### Create a connection to SoftLayer DNS Service
|
@@ -0,0 +1,81 @@
|
|
1
|
+
### Key Pair Examples
|
2
|
+
|
3
|
+
These examples all assume you have `~/.fog` which contains the following
|
4
|
+
|
5
|
+
```yaml
|
6
|
+
default:
|
7
|
+
softlayer_username: example-username
|
8
|
+
softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
|
9
|
+
softlayer_default_domain: example.com
|
10
|
+
```
|
11
|
+
|
12
|
+
#### Create a connection to SoftLayer Compute Service
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
require 'fog/softlayer'
|
16
|
+
@sl = Fog::Compute[:softlayer]
|
17
|
+
```
|
18
|
+
|
19
|
+
#### Key Pair Basics
|
20
|
+
1. Create
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
kp1 = @sl.key_pairs.create(:label => 'my-new-key', :key => 'ssh-rsa AAAAxbU2lx...')
|
24
|
+
# => <Fog::Compute::Softlayer::KeyPair>
|
25
|
+
kp2 = @sl.key_pairs.new
|
26
|
+
kp2.label = 'my-new-new-key'
|
27
|
+
kp2.key = 'ssh-rsa AAAAxbU2lx...'
|
28
|
+
kp2.save
|
29
|
+
# => <Fog::Compute::Softlayer::KeyPair>
|
30
|
+
```
|
31
|
+
|
32
|
+
1. Get
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
# By id:
|
36
|
+
kp = @sl.key_pairs.get(123456)
|
37
|
+
# => <Fog::Compute::Softlayer::KeyPair>
|
38
|
+
|
39
|
+
# By label:
|
40
|
+
kp = @sl.key_pairs.by_label('my-new-key')
|
41
|
+
# => <Fog::Compute::Softlayer::KeyPair>
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
1. Destroy
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
kp = @sl.key_pairs.by_label('my-new-key')
|
49
|
+
# => <Fog::Compute::Softlayer::KeyPair>
|
50
|
+
kp.destroy
|
51
|
+
```
|
52
|
+
|
53
|
+
|
54
|
+
### Key Pairs with Servers
|
55
|
+
1. Create a server with one or more key pairs
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
the_first_key = @sl.key_pairs.by_label('my-new-key')
|
59
|
+
# => <Fog::Compute::Softlayer::KeyPair>
|
60
|
+
the_second_key = @sl.key_pairs.by_label('my-other-new-key')
|
61
|
+
# => <Fog::Compute::Softlayer::KeyPair>
|
62
|
+
|
63
|
+
opts = {
|
64
|
+
:flavor_id => 'm1.small',
|
65
|
+
:os_code => 'UBUNTU_LATEST',
|
66
|
+
:datacenter => 'hkg02',
|
67
|
+
:name => 'cphrmky',
|
68
|
+
:key_pairs => [ the_first_key, the_second_key ]
|
69
|
+
}
|
70
|
+
@sl.servers.create(opts)
|
71
|
+
# => <Fog::Compute::Softlayer::Server>
|
72
|
+
```
|
73
|
+
|
74
|
+
1. Look at the key pairs on a server.
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
server = @sl.servers.get(12345)
|
78
|
+
server.key_pairs
|
79
|
+
# => [ <Fog::Compute::Softlayer::Server>,
|
80
|
+
# <Fog::Compute::Softlayer::Server>]
|
81
|
+
```
|
data/examples/network.md
CHANGED
@@ -7,8 +7,9 @@ These examples all assume you have `~/.fog` which contains the following
|
|
7
7
|
|
8
8
|
|
9
9
|
```yaml
|
10
|
-
|
11
|
-
|
10
|
+
default:
|
11
|
+
softlayer_username: example-username
|
12
|
+
softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
|
12
13
|
```
|
13
14
|
|
14
15
|
#### Create a connection to SoftLayer Network
|
data/examples/storage.md
CHANGED
@@ -4,9 +4,10 @@ These examples all assume you have `~/.fog` which contains the following
|
|
4
4
|
|
5
5
|
|
6
6
|
```yaml
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
default:
|
8
|
+
softlayer_username: example-username
|
9
|
+
softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
|
10
|
+
softlayer_cluster: cluster # currently supported clusters are dal05, sng01, ams01
|
10
11
|
```
|
11
12
|
|
12
13
|
#### Create a connection to SoftLayer Object Storage
|
data/examples/tags.md
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
These examples all assume you have `~/.fog` which contains the following
|
4
4
|
|
5
5
|
```yaml
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
default:
|
7
|
+
softlayer_username: example-username
|
8
|
+
softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
|
9
|
+
softlayer_default_domain: example.com
|
9
10
|
```
|
10
11
|
|
11
12
|
#### Create a connection to SoftLayer Compute Service
|
data/lib/fog.rb
CHANGED
@@ -10,12 +10,6 @@
|
|
10
10
|
__LIB_DIR__ = File.expand_path(File.dirname(__FILE__))
|
11
11
|
$LOAD_PATH.unshift __LIB_DIR__ unless $LOAD_PATH.include?(__LIB_DIR__)
|
12
12
|
|
13
|
-
# Use fog and core
|
14
13
|
require 'fog/core'
|
15
|
-
require 'fog'
|
16
|
-
|
17
|
-
# Previously treated as "core"
|
18
|
-
# data exchange specific (to be extracted and used on a per provider basis)
|
19
14
|
require 'fog/json'
|
20
|
-
|
21
15
|
require 'fog/softlayer'
|
@@ -17,8 +17,7 @@ module Fog
|
|
17
17
|
requires :softlayer_username, :softlayer_api_key
|
18
18
|
|
19
19
|
# Excon connection settings
|
20
|
-
recognizes :softlayer_api_url
|
21
|
-
recognizes :softlayer_default_domain
|
20
|
+
recognizes :softlayer_api_url, :softlayer_default_domain, :softlayer_default_datacenter
|
22
21
|
|
23
22
|
|
24
23
|
model_path 'fog/softlayer/models/compute'
|
@@ -26,6 +25,8 @@ module Fog
|
|
26
25
|
model :flavor
|
27
26
|
collection :images
|
28
27
|
model :image
|
28
|
+
collection :key_pairs
|
29
|
+
model :key_pair
|
29
30
|
collection :servers
|
30
31
|
model :server
|
31
32
|
collection :tags
|
@@ -34,37 +35,42 @@ module Fog
|
|
34
35
|
request_path 'fog/softlayer/requests/compute'
|
35
36
|
request :create_bare_metal_server
|
36
37
|
request :create_bare_metal_tags
|
38
|
+
request :create_key_pair
|
37
39
|
request :create_vm
|
38
40
|
request :create_vms
|
39
41
|
request :create_vm_tags
|
40
42
|
request :delete_bare_metal_server
|
41
43
|
request :delete_bare_metal_tags
|
44
|
+
request :delete_key_pair
|
42
45
|
request :delete_vm
|
43
46
|
request :delete_vm_tags
|
44
47
|
request :describe_tags
|
45
48
|
request :get_bare_metal_server
|
46
49
|
request :get_bare_metal_servers
|
47
50
|
request :get_bare_metal_tags
|
51
|
+
request :get_key_pair
|
52
|
+
request :get_key_pairs
|
48
53
|
request :get_references_by_tag_name
|
49
54
|
request :get_tag
|
50
55
|
request :get_vm_tags
|
51
56
|
request :get_vm
|
52
57
|
request :get_vms
|
58
|
+
request :update_key_pair
|
53
59
|
|
54
60
|
# The Mock Service allows you to run a fake instance of the Service
|
55
61
|
# which makes no real connections.
|
56
62
|
#
|
57
63
|
#
|
58
64
|
class Mock
|
59
|
-
attr_accessor :default_domain
|
60
65
|
include Fog::Softlayer::Slapi
|
61
66
|
include Fog::Softlayer::Compute::Shared
|
62
|
-
attr_accessor :virtual_guests, :bare_metal_servers
|
67
|
+
attr_accessor :default_domain, :virtual_guests, :bare_metal_servers, :softlayer_default_domain, :softlayer_default_datacenter
|
63
68
|
|
64
69
|
def initialize(args)
|
65
70
|
@virtual_guests = []
|
66
71
|
@bare_metal_servers = []
|
67
72
|
@tags = []
|
73
|
+
@key_pairs = []
|
68
74
|
super(args)
|
69
75
|
end
|
70
76
|
|
@@ -94,13 +100,16 @@ module Fog
|
|
94
100
|
# Makes real connections to Softlayer.
|
95
101
|
#
|
96
102
|
class Real
|
97
|
-
attr_accessor :
|
103
|
+
attr_accessor :softlayer_default_domain
|
104
|
+
attr_accessor :softlayer_default_datacenter
|
98
105
|
include Fog::Softlayer::Slapi
|
99
106
|
include Fog::Softlayer::Compute::Shared
|
100
107
|
|
101
108
|
def initialize(options={})
|
102
109
|
@softlayer_api_key = options[:softlayer_api_key]
|
103
110
|
@softlayer_username = options[:softlayer_username]
|
111
|
+
@softlayer_default_domain = options[:softlayer_default_domain]
|
112
|
+
@softlayer_default_datacenter = options[:softlayer_default_datacenter]
|
104
113
|
end
|
105
114
|
|
106
115
|
def request(service, path, options = {})
|
@@ -108,7 +117,6 @@ module Fog
|
|
108
117
|
Fog::Softlayer::Slapi.slapi_request(service, path, options)
|
109
118
|
end
|
110
119
|
|
111
|
-
|
112
120
|
def list_servers
|
113
121
|
(self.get_vms.body.map {|s| s['bare_metal'] = false; s } << self.get_bare_metal_servers.body.map {|s| s['bare_metal'] = true; s}).flatten
|
114
122
|
end
|
@@ -123,11 +131,11 @@ end
|
|
123
131
|
|
124
132
|
## some helpers for some dirty work
|
125
133
|
class String
|
126
|
-
def
|
134
|
+
def softlayer_camelize
|
127
135
|
self.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
128
136
|
end
|
129
137
|
|
130
|
-
def
|
138
|
+
def softlayer_underscore
|
131
139
|
self.gsub(/::/, '/').
|
132
140
|
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
133
141
|
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
data/lib/fog/softlayer/core.rb
CHANGED
@@ -82,7 +82,7 @@ module Fog
|
|
82
82
|
# Try to smallCamelCase the path before appending it to the @request_url
|
83
83
|
#
|
84
84
|
def self.set_sl_path(path)
|
85
|
-
path = path.to_s.
|
85
|
+
path = path.to_s.softlayer_underscore.softlayer_camelize
|
86
86
|
path.fix_convention_exceptions
|
87
87
|
@request_url += "/#{path}.json"
|
88
88
|
end
|
@@ -144,15 +144,17 @@ end
|
|
144
144
|
|
145
145
|
## some helpers for some dirty work
|
146
146
|
class String
|
147
|
-
def
|
147
|
+
def softlayer_camelize
|
148
148
|
self.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
149
149
|
end
|
150
150
|
|
151
151
|
def fix_convention_exceptions
|
152
|
-
|
152
|
+
# SLAPI WHY U No Follow Own Convention!?
|
153
|
+
self.gsub!(/ipaddress/i, 'IpAddress')
|
154
|
+
self.gsub!(/loadbalancer/i, 'LoadBalancer')
|
153
155
|
end
|
154
156
|
|
155
|
-
def
|
157
|
+
def softlayer_underscore
|
156
158
|
self.gsub(/::/, '/').
|
157
159
|
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
158
160
|
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
data/lib/fog/softlayer/dns.rb
CHANGED
@@ -132,7 +132,7 @@ module Fog
|
|
132
132
|
# Try to smallCamelCase the path before appending it to the @request_url
|
133
133
|
#
|
134
134
|
def set_sl_path(path)
|
135
|
-
path = path.to_s.
|
135
|
+
path = path.to_s.softlayer_underscore.softlayer_camelize
|
136
136
|
@request_url += "/#{path}.json"
|
137
137
|
end
|
138
138
|
|
@@ -149,11 +149,11 @@ end
|
|
149
149
|
|
150
150
|
## some helpers for some dirty work
|
151
151
|
class String
|
152
|
-
def
|
152
|
+
def softlayer_camelize
|
153
153
|
self.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
154
154
|
end
|
155
155
|
|
156
|
-
def
|
156
|
+
def softlayer_underscore
|
157
157
|
self.gsub(/::/, '/').
|
158
158
|
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
159
159
|
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
|
3
|
+
# © Copyright IBM Corporation 2014.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'fog/core/model'
|
9
|
+
|
10
|
+
module Fog
|
11
|
+
module Compute
|
12
|
+
class Softlayer
|
13
|
+
class KeyPair < Fog::Model
|
14
|
+
identity :id
|
15
|
+
|
16
|
+
attribute :label
|
17
|
+
attribute :create_date, :aliases => 'createDate'
|
18
|
+
attribute :modify_date, :aliases => 'modifyDate'
|
19
|
+
attribute :note, :aliases => 'notes'
|
20
|
+
attribute :key
|
21
|
+
|
22
|
+
def save
|
23
|
+
identity ? update : create
|
24
|
+
end
|
25
|
+
|
26
|
+
def create
|
27
|
+
requires :key, :label
|
28
|
+
response = service.create_key_pair(attributes).body
|
29
|
+
merge_attributes(response)
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def update
|
34
|
+
requires :id
|
35
|
+
merge_attributes(service.update_key_pair(self.id, self.attributes).body)
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
requires :id
|
41
|
+
service.delete_key_pair(self.id)
|
42
|
+
true
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
|
3
|
+
# © Copyright IBM Corporation 2014.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'fog/core/collection'
|
9
|
+
require 'fog/softlayer/models/compute/key_pair'
|
10
|
+
|
11
|
+
module Fog
|
12
|
+
module Compute
|
13
|
+
class Softlayer
|
14
|
+
class KeyPairs < Fog::Collection
|
15
|
+
model Fog::Compute::Softlayer::KeyPair
|
16
|
+
|
17
|
+
def all
|
18
|
+
data = service.get_key_pairs.body
|
19
|
+
load(data)
|
20
|
+
end
|
21
|
+
|
22
|
+
def get(id)
|
23
|
+
if key_pair = service.get_key_pair(id).body
|
24
|
+
new(key_pair)
|
25
|
+
end
|
26
|
+
rescue Fog::Network::Softlayer::NotFound
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def by_label(label)
|
31
|
+
all.select { |key_pair| key_pair.label == label }.first
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -24,10 +24,10 @@ module Fog
|
|
24
24
|
attribute :public_ip, :aliases => 'primaryIpAddress'
|
25
25
|
attribute :flavor_id
|
26
26
|
attribute :bare_metal, :type => :boolean
|
27
|
-
attribute :os_code
|
27
|
+
attribute :os_code
|
28
28
|
attribute :image_id, :type => :squash
|
29
29
|
attribute :ephemeral_storage, :aliases => 'localDiskFlag'
|
30
|
-
attribute :
|
30
|
+
attribute :key_pairs, :aliases => 'sshKeys'
|
31
31
|
|
32
32
|
# Times
|
33
33
|
attribute :created_at, :aliases => ['createDate', 'provisionDate'], :type => :time
|
@@ -42,6 +42,7 @@ module Fog
|
|
42
42
|
attribute :global_identifier, :aliases => 'globalIdentifier'
|
43
43
|
attribute :hourly_billing_flag, :aliases => 'hourlyBillingFlag'
|
44
44
|
attribute :tags, :aliases => 'tagReferences'
|
45
|
+
attribute :private_network_only, :aliases => 'privateNetworkOnlyFlag'
|
45
46
|
|
46
47
|
def initialize(attributes = {})
|
47
48
|
# Forces every request inject bare_metal parameter
|
@@ -123,32 +124,56 @@ module Fog
|
|
123
124
|
if self.private_vlan
|
124
125
|
attributes[:private_vlan] = { :networkVlan => { :id => self.private_vlan.id } }
|
125
126
|
end
|
127
|
+
if self.key_pairs
|
128
|
+
attributes[:key_pairs].map! { |key| { :id => key.id } }
|
129
|
+
end
|
126
130
|
remap_attributes(attributes, attributes_mapping)
|
127
131
|
clean_attributes
|
128
132
|
end
|
129
133
|
|
130
|
-
def
|
131
|
-
attributes[
|
134
|
+
def os_code
|
135
|
+
attributes['operatingSystem']['softwareLicense']['softwareDescription']['referenceCode'] if attributes['operatingSystem']
|
132
136
|
end
|
133
137
|
|
134
138
|
def private_vlan
|
135
139
|
attributes[:private_vlan] ||= _get_private_vlan
|
136
140
|
end
|
137
141
|
|
138
|
-
def
|
142
|
+
def private_vlan=(value)
|
139
143
|
unless value.is_a?(Integer) or value.is_a?(Fog::Network::Softlayer::Network)
|
140
144
|
raise ArgumentError, "vlan argument for #{self.class.name}##{__method__} must be Integer or Fog::Network::Softlayer::Network."
|
141
145
|
end
|
142
146
|
value = Fog::Network[:softlayer].networks.get(value) if value.is_a?(Integer)
|
143
|
-
attributes[:
|
147
|
+
attributes[:private_vlan] = value
|
144
148
|
end
|
145
149
|
|
146
|
-
def
|
150
|
+
def key_pairs
|
151
|
+
attributes[:key_pairs]
|
152
|
+
end
|
153
|
+
|
154
|
+
def key_pairs=(keys)
|
155
|
+
raise ArgumentError, "Argument #{local_variables.first.to_s} for #{self.class.name}##{__method__} must be Array." unless keys.is_a?(Array)
|
156
|
+
attributes[:key_pairs] = []
|
157
|
+
keys.map do |key|
|
158
|
+
key = self.symbolize_keys(key) if key.is_a?(Hash)
|
159
|
+
unless key.is_a?(Fog::Compute::Softlayer::KeyPair) or (key.is_a?(Hash) and key[:id])
|
160
|
+
raise ArgumentError, "Elements of keys array for #{self.class.name}##{__method__} must be a Hash with key 'id', or Fog::Compute::Softlayer::KeyPair"
|
161
|
+
end
|
162
|
+
key = service.key_pairs.get(key[:id]) unless key.is_a?(Fog::Compute::Softlayer::KeyPair)
|
163
|
+
attributes[:key_pairs] << key
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def vlan
|
168
|
+
attributes[:vlan] ||= _get_vlan
|
169
|
+
end
|
170
|
+
|
171
|
+
def vlan=(value)
|
147
172
|
unless value.is_a?(Integer) or value.is_a?(Fog::Network::Softlayer::Network)
|
148
173
|
raise ArgumentError, "vlan argument for #{self.class.name}##{__method__} must be Integer or Fog::Network::Softlayer::Network."
|
149
174
|
end
|
150
175
|
value = Fog::Network[:softlayer].networks.get(value) if value.is_a?(Integer)
|
151
|
-
attributes[:
|
176
|
+
attributes[:vlan] = value
|
152
177
|
end
|
153
178
|
|
154
179
|
def ram=(set)
|
@@ -212,7 +237,6 @@ module Fog
|
|
212
237
|
# * BUILD -> ERROR (on error)
|
213
238
|
def save
|
214
239
|
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
215
|
-
|
216
240
|
copy = self.dup
|
217
241
|
copy.pre_save
|
218
242
|
|
@@ -263,6 +287,8 @@ module Fog
|
|
263
287
|
:os_code => :operatingSystemReferenceCode,
|
264
288
|
:vlan => :primaryNetworkComponent,
|
265
289
|
:private_vlan => :primaryBackendNetworkComponent,
|
290
|
+
:key_pairs => :sshKeys,
|
291
|
+
:private_network_only => :privateNetworkOnlyFlag,
|
266
292
|
|
267
293
|
}
|
268
294
|
|
@@ -331,7 +357,8 @@ module Fog
|
|
331
357
|
def set_defaults
|
332
358
|
attributes[:hourly_billing_flag] = true if attributes[:hourly_billing_flag].nil?
|
333
359
|
attributes[:ephemeral_storage] = false if attributes[:ephemeral_storage].nil?
|
334
|
-
attributes[:domain] = service.
|
360
|
+
attributes[:domain] = service.softlayer_default_domain if service.softlayer_default_domain and attributes[:domain].nil?
|
361
|
+
self.datacenter = service.softlayer_default_datacenter if service.softlayer_default_datacenter and attributes[:datacenter].nil?
|
335
362
|
end
|
336
363
|
|
337
364
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
|
3
|
+
# © Copyright IBM Corporation 2014.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
module Fog
|
8
|
+
module Compute
|
9
|
+
class Softlayer
|
10
|
+
|
11
|
+
class Mock
|
12
|
+
|
13
|
+
def create_key_pair(opts)
|
14
|
+
response = Excon::Response.new
|
15
|
+
|
16
|
+
response.status = 200
|
17
|
+
response.body = []
|
18
|
+
|
19
|
+
response.body = {
|
20
|
+
"createDate" => Time.now.iso8601,
|
21
|
+
"fingerprint" => "1a:1a:1a:1a:1a:1a:1a:1a:1a:1a:1a:1a:1a:1a:1a:1a",
|
22
|
+
"id" => Fog::Mock.random_numbers(5).to_i,
|
23
|
+
"key" => opts[:key],
|
24
|
+
"label" => opts[:label],
|
25
|
+
"modifyDate" => nil
|
26
|
+
}
|
27
|
+
|
28
|
+
@key_pairs.push(response.body)
|
29
|
+
response
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Real
|
34
|
+
def create_key_pair(opts)
|
35
|
+
request(:security_ssh_key, :create_object, :body => opts, :http_method => :post)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
|
3
|
+
# © Copyright IBM Corporation 2014.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
module Fog
|
8
|
+
module Compute
|
9
|
+
class Softlayer
|
10
|
+
|
11
|
+
class Mock
|
12
|
+
|
13
|
+
def delete_key_pair(id)
|
14
|
+
response = Excon::Response.new
|
15
|
+
response.status = 200
|
16
|
+
if @key_pairs.reject! { |kp| kp['id'] == id }.nil?
|
17
|
+
response.status = 404
|
18
|
+
response.body = {
|
19
|
+
"error" => "Unable to find object with id of '#{id}'.",
|
20
|
+
"code" => "SoftLayer_Exception_ObjectNotFound"
|
21
|
+
}
|
22
|
+
else
|
23
|
+
response.body = true
|
24
|
+
end
|
25
|
+
response
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Real
|
30
|
+
def delete_key_pair(id)
|
31
|
+
request(:security_ssh_key, id, :http_method => :delete)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -26,7 +26,7 @@ module Fog
|
|
26
26
|
|
27
27
|
class Real
|
28
28
|
def get_bare_metal_server(identifier)
|
29
|
-
request(:hardware_server, identifier, :expected => [200, 404], :query => 'objectMask=mask[datacenter,tagReferences,memory,provisionDate,processorCoreAmount,hardDrives,datacenter,hourlyBillingFlag,operatingSystem.
|
29
|
+
request(:hardware_server, identifier, :expected => [200, 404], :query => 'objectMask=mask[datacenter,tagReferences,memory,provisionDate,processorCoreAmount,hardDrives,datacenter,hourlyBillingFlag,operatingSystem.softwareLicense.softwareDescription.referenceCode,sshKeys.id,privateNetworkOnlyFlag]')
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -20,7 +20,7 @@ module Fog
|
|
20
20
|
|
21
21
|
class Real
|
22
22
|
def get_bare_metal_servers
|
23
|
-
request(:account, :get_hardware, :query => 'objectMask=mask[datacenter,tagReferences,memory,processorCoreAmount,hardDrives,datacenter,hourlyBillingFlag,operatingSystem.
|
23
|
+
request(:account, :get_hardware, :query => 'objectMask=mask[datacenter,tagReferences,memory,processorCoreAmount,hardDrives,datacenter,hourlyBillingFlag,operatingSystem.softwareLicense.softwareDescription.referenceCode,sshKeys.id,privateNetworkOnlyFlag]')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
|
3
|
+
# © Copyright IBM Corporation 2014.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
module Fog
|
8
|
+
module Compute
|
9
|
+
class Softlayer
|
10
|
+
|
11
|
+
class Mock
|
12
|
+
def get_key_pair(id)
|
13
|
+
response = Excon::Response.new
|
14
|
+
response.status = 200
|
15
|
+
response.body = key_pair = @key_pairs.select { |kp| kp['id'] == id }.first
|
16
|
+
|
17
|
+
if key_pair.nil?
|
18
|
+
response.body = {
|
19
|
+
"error"=>"Unable to find object with id of '#{id}'.",
|
20
|
+
"code"=>"SoftLayer_Exception_ObjectNotFound"
|
21
|
+
}
|
22
|
+
response.status = 404
|
23
|
+
end
|
24
|
+
response
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
class Real
|
30
|
+
def get_key_pair(id)
|
31
|
+
request(:security_ssh_key, id)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
|
3
|
+
# © Copyright IBM Corporation 2014.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
|
8
|
+
module Fog
|
9
|
+
module Compute
|
10
|
+
class Softlayer
|
11
|
+
|
12
|
+
class Mock
|
13
|
+
def get_key_pairs
|
14
|
+
response = Excon::Response.new
|
15
|
+
response.body = @key_pairs
|
16
|
+
response.status = 200
|
17
|
+
response
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
class Real
|
23
|
+
def get_key_pairs
|
24
|
+
request(:account, :get_ssh_keys)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -26,7 +26,7 @@ module Fog
|
|
26
26
|
|
27
27
|
class Real
|
28
28
|
def get_vm(identifier)
|
29
|
-
request(:virtual_guest, identifier, :expected => [200, 404], :query => 'objectMask=mask[datacenter,tagReferences,blockDevices,blockDeviceTemplateGroup.globalIdentifier,operatingSystem.
|
29
|
+
request(:virtual_guest, identifier, :expected => [200, 404], :query => 'objectMask=mask[datacenter,tagReferences,blockDevices,blockDeviceTemplateGroup.globalIdentifier,operatingSystem.softwareLicense.softwareDescription.referenceCode,sshKeys.id,privateNetworkOnlyFlag]')
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -20,7 +20,7 @@ module Fog
|
|
20
20
|
|
21
21
|
class Real
|
22
22
|
def get_vms
|
23
|
-
request(:account, :get_virtual_guests, :query => 'objectMask=mask[datacenter,tagReferences,blockDevices,blockDeviceTemplateGroup.globalIdentifier,operatingSystem.
|
23
|
+
request(:account, :get_virtual_guests, :query => 'objectMask=mask[datacenter,tagReferences,blockDevices,blockDeviceTemplateGroup.globalIdentifier,operatingSystem.softwareLicense.softwareDescription.referenceCode,primaryNetworkComponent.networkVlan,sshKeys.id,privateNetworkOnlyFlag]')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
|
3
|
+
# © Copyright IBM Corporation 2014.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
module Fog
|
8
|
+
module Compute
|
9
|
+
class Softlayer
|
10
|
+
|
11
|
+
class Mock
|
12
|
+
|
13
|
+
def update_key_pair(id, opts)
|
14
|
+
response = Excon::Response.new
|
15
|
+
response.status = 200
|
16
|
+
|
17
|
+
key_pair, index = @key_pairs.each_with_index.map { |kp, i| [kp, i] if kp['id'] == id }.compact.flatten
|
18
|
+
|
19
|
+
if key_pair.nil?
|
20
|
+
response.status = 404
|
21
|
+
response.body = {
|
22
|
+
"error" => "Unable to find object with id of '#{id}'.",
|
23
|
+
"code" => "SoftLayer_Exception_ObjectNotFound"
|
24
|
+
}
|
25
|
+
else
|
26
|
+
|
27
|
+
@key_pairs[index] = key_pair.merge(opts)
|
28
|
+
response.body = true
|
29
|
+
end
|
30
|
+
response
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Real
|
35
|
+
def update_key_pair(id, opts)
|
36
|
+
request(:security_ssh_key, id, :body => opts, :http_method => :put)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -86,7 +86,7 @@ module Fog
|
|
86
86
|
@api_key = options[:softlayer_api_key]
|
87
87
|
@username = options[:softlayer_username]
|
88
88
|
@cluster = options[:softlayer_cluster]
|
89
|
-
@storage_account = options[:softlayer_storage_account] || default_storage_account
|
89
|
+
@storage_account = options[:softlayer_storage_account] || default_storage_account(options[:softlayer_username], options[:softlayer_api_key])
|
90
90
|
@connection_options = options[:connection_options] || {}
|
91
91
|
authenticate
|
92
92
|
@persistent = options[:persistent] || false
|
@@ -183,8 +183,8 @@ module Fog
|
|
183
183
|
true
|
184
184
|
end
|
185
185
|
|
186
|
-
def default_storage_account
|
187
|
-
slapi = Fog::Compute
|
186
|
+
def default_storage_account(username, api_key)
|
187
|
+
slapi = Fog::Compute.new(:provider => :softlayer, :softlayer_username => username, :softlayer_api_key => api_key).request(:account, :get_hub_network_storage)
|
188
188
|
slapi.body.map { |store| store['username'] }.first if slapi.body and slapi.body.instance_of? Array
|
189
189
|
end
|
190
190
|
|
@@ -120,6 +120,17 @@ class Softlayer
|
|
120
120
|
|
121
121
|
end
|
122
122
|
|
123
|
+
module KeyPair
|
124
|
+
KP = {
|
125
|
+
"createDate" => String,
|
126
|
+
"fingerprint" => String,
|
127
|
+
"id" => Integer,
|
128
|
+
"key" => String,
|
129
|
+
"label" => String,
|
130
|
+
"modifyDate" => Fog::Nullable::String,
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
123
134
|
module Collected
|
124
135
|
SERVER = {
|
125
136
|
:id => Fog::Nullable::Integer,
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
|
3
|
+
# © Copyright IBM Corporation 2014.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
|
8
|
+
Shindo.tests("Fog::Compute[:softlayer] | KeyPair model", ["softlayer"]) do
|
9
|
+
pending unless Fog.mocking?
|
10
|
+
|
11
|
+
@sl_connection = Fog::Compute[:softlayer]
|
12
|
+
@key_gen = Proc.new { string='ssh-rsa '; while string.length < 380 do; string << Fog::Mock.random_base64(1); end; string; }
|
13
|
+
@kp1 = @sl_connection.key_pairs.create(:label => 'test-key-1', :key => @key_gen.call)
|
14
|
+
|
15
|
+
tests("success") do
|
16
|
+
|
17
|
+
tests("#label=") do
|
18
|
+
returns('new-label') { @kp1.label = 'new-label' }
|
19
|
+
end
|
20
|
+
|
21
|
+
tests("#label") do
|
22
|
+
returns('new-label') { @kp1.label}
|
23
|
+
end
|
24
|
+
|
25
|
+
tests("#key=") do
|
26
|
+
@new_key_value = @key_gen.call
|
27
|
+
returns(@new_key_value) { @kp1.key = @new_key_value }
|
28
|
+
end
|
29
|
+
|
30
|
+
tests("#key") do
|
31
|
+
returns(@new_key_value) { @kp1.key }
|
32
|
+
end
|
33
|
+
|
34
|
+
tests("#create(:label => 'test-key-2', :key => #{@key_gen.call}") do
|
35
|
+
data_matches_schema(Fog::Compute::Softlayer::KeyPair) { @sl_connection.key_pairs.create(:label => 'test-key-2', :key => @key_gen.call)}
|
36
|
+
end
|
37
|
+
|
38
|
+
tests("#destroy") do
|
39
|
+
returns(true) { @sl_connection.key_pairs.first.destroy }
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
tests ("failure") do
|
45
|
+
# ToDo: Failure cases.
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
|
3
|
+
# © Copyright IBM Corporation 2014.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
|
8
|
+
Shindo.tests("Fog::Compute[:softlayer] | key_pair requests", ["softlayer"]) do
|
9
|
+
|
10
|
+
@sl_connection = Fog::Compute[:softlayer]
|
11
|
+
|
12
|
+
opts = { :flavor_id => 'm1.small', :os_code => 'UBUNTU_LATEST', :name => 'matt', :datacenter => 'dal05', :domain => 'example.com', :bare_metal => false}
|
13
|
+
@vm = @sl_connection.servers.create(opts)
|
14
|
+
|
15
|
+
opts[:bare_metal] = true
|
16
|
+
@bmc = @sl_connection.servers.create(opts)
|
17
|
+
|
18
|
+
@key_gen = Proc.new { string='ssh-rsa '; while string.length < 380 do; string << Fog::Mock.random_base64(1); end; string; }
|
19
|
+
|
20
|
+
@kp1 = @sl_connection.key_pairs.new
|
21
|
+
@kp1.label = 'test-key-1'
|
22
|
+
@kp1.key = @key_gen.call
|
23
|
+
@kp1.save
|
24
|
+
|
25
|
+
|
26
|
+
tests('success') do
|
27
|
+
|
28
|
+
tests("#create_key_pair") do
|
29
|
+
key = @sl_connection.create_key_pair(:key => @key_gen.call, :label => 'test-key-tmp')
|
30
|
+
@kp2 = @sl_connection.key_pairs.get(key.body['id'])
|
31
|
+
returns(200) { key.status }
|
32
|
+
data_matches_schema(Integer) { key.body['id'] }
|
33
|
+
end
|
34
|
+
|
35
|
+
tests("#get_key_pairs") do
|
36
|
+
data_matches_schema([Softlayer::Compute::Formats::KeyPair::KP]) { @sl_connection.get_key_pairs.body}
|
37
|
+
returns(200) { @sl_connection.get_key_pairs.status }
|
38
|
+
returns(2) { @sl_connection.get_key_pairs.body.count }
|
39
|
+
end
|
40
|
+
|
41
|
+
tests("#get_key_pair(#{@kp1.id}") do
|
42
|
+
data_matches_schema(Softlayer::Compute::Formats::KeyPair::KP) { @sl_connection.get_key_pair(@kp1.id).body }
|
43
|
+
end
|
44
|
+
|
45
|
+
tests("#update_key_pair(#{@kp1.id}, 'label' => 'some-new-name'}") do
|
46
|
+
returns(true) { @sl_connection.update_key_pair(@kp1.id, 'label' => 'some-new-name').body }
|
47
|
+
returns('some-new-name') { @sl_connection.get_key_pair(@kp1.id).body['label'] }
|
48
|
+
end
|
49
|
+
|
50
|
+
tests("#delete_key_pair(#{@kp1.id}") do
|
51
|
+
returns(true) { @sl_connection.delete_key_pair(@kp1.id).body }
|
52
|
+
returns(1) { @sl_connection.get_key_pairs.body.count }
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
tests('failure') do
|
58
|
+
|
59
|
+
tests("#get_key_pair").raises(ArgumentError) do
|
60
|
+
@sl_connection.get_key_pair
|
61
|
+
end
|
62
|
+
|
63
|
+
tests("#get_key_pair(#{@kp1.id}") do
|
64
|
+
returns(404) { @sl_connection.get_key_pair(@kp1.id).status }
|
65
|
+
end
|
66
|
+
|
67
|
+
tests("#update_key_pair(#{@kp1.id}, 'label' => 'random thing'") do
|
68
|
+
returns(404) { @sl_connection.update_key_pair(@kp1.id, 'label' => 'random thing' ).status }
|
69
|
+
end
|
70
|
+
|
71
|
+
tests("#delete_key_pair(#{@kp1.id}") do
|
72
|
+
returns(404) { @sl_connection.delete_key_pair(@kp1.id).status }
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -9,7 +9,7 @@ Shindo.tests("Fog::Compute[:softlayer] | tag requests", ["softlayer"]) do
|
|
9
9
|
|
10
10
|
@sl_connection = Fog::Compute[:softlayer]
|
11
11
|
|
12
|
-
opts = { :flavor_id => 'm1.small', :os_code => 'UBUNTU_LATEST', :name => 'matt', :datacenter => 'dal05', :bare_metal => false}
|
12
|
+
opts = { :flavor_id => 'm1.small', :os_code => 'UBUNTU_LATEST', :name => 'matt', :datacenter => 'dal05', :domain => 'example.com', :bare_metal => false}
|
13
13
|
@vm = @sl_connection.servers.create(opts)
|
14
14
|
|
15
15
|
opts[:bare_metal] = true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-softlayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Eldridge
|
@@ -200,6 +200,7 @@ files:
|
|
200
200
|
- docs/fog-softlayer-CLA.pdf
|
201
201
|
- examples/compute.md
|
202
202
|
- examples/dns.md
|
203
|
+
- examples/key_pairs.md
|
203
204
|
- examples/network.md
|
204
205
|
- examples/storage.md
|
205
206
|
- examples/tags.md
|
@@ -216,6 +217,8 @@ files:
|
|
216
217
|
- lib/fog/softlayer/models/compute/flavors.rb
|
217
218
|
- lib/fog/softlayer/models/compute/image.rb
|
218
219
|
- lib/fog/softlayer/models/compute/images.rb
|
220
|
+
- lib/fog/softlayer/models/compute/key_pair.rb
|
221
|
+
- lib/fog/softlayer/models/compute/key_pairs.rb
|
219
222
|
- lib/fog/softlayer/models/compute/server.rb
|
220
223
|
- lib/fog/softlayer/models/compute/servers.rb
|
221
224
|
- lib/fog/softlayer/models/compute/tag.rb
|
@@ -241,22 +244,27 @@ files:
|
|
241
244
|
- lib/fog/softlayer/network.rb
|
242
245
|
- lib/fog/softlayer/requests/compute/create_bare_metal_server.rb
|
243
246
|
- lib/fog/softlayer/requests/compute/create_bare_metal_tags.rb
|
247
|
+
- lib/fog/softlayer/requests/compute/create_key_pair.rb
|
244
248
|
- lib/fog/softlayer/requests/compute/create_vm.rb
|
245
249
|
- lib/fog/softlayer/requests/compute/create_vm_tags.rb
|
246
250
|
- lib/fog/softlayer/requests/compute/create_vms.rb
|
247
251
|
- lib/fog/softlayer/requests/compute/delete_bare_metal_server.rb
|
248
252
|
- lib/fog/softlayer/requests/compute/delete_bare_metal_tags.rb
|
253
|
+
- lib/fog/softlayer/requests/compute/delete_key_pair.rb
|
249
254
|
- lib/fog/softlayer/requests/compute/delete_vm.rb
|
250
255
|
- lib/fog/softlayer/requests/compute/delete_vm_tags.rb
|
251
256
|
- lib/fog/softlayer/requests/compute/describe_tags.rb
|
252
257
|
- lib/fog/softlayer/requests/compute/get_bare_metal_server.rb
|
253
258
|
- lib/fog/softlayer/requests/compute/get_bare_metal_servers.rb
|
254
259
|
- lib/fog/softlayer/requests/compute/get_bare_metal_tags.rb
|
260
|
+
- lib/fog/softlayer/requests/compute/get_key_pair.rb
|
261
|
+
- lib/fog/softlayer/requests/compute/get_key_pairs.rb
|
255
262
|
- lib/fog/softlayer/requests/compute/get_references_by_tag_name.rb
|
256
263
|
- lib/fog/softlayer/requests/compute/get_tag.rb
|
257
264
|
- lib/fog/softlayer/requests/compute/get_vm.rb
|
258
265
|
- lib/fog/softlayer/requests/compute/get_vm_tags.rb
|
259
266
|
- lib/fog/softlayer/requests/compute/get_vms.rb
|
267
|
+
- lib/fog/softlayer/requests/compute/update_key_pair.rb
|
260
268
|
- lib/fog/softlayer/requests/dns/create_domain.rb
|
261
269
|
- lib/fog/softlayer/requests/dns/create_record.rb
|
262
270
|
- lib/fog/softlayer/requests/dns/delete_domain.rb
|
@@ -327,6 +335,7 @@ files:
|
|
327
335
|
- tests/softlayer/helper.rb
|
328
336
|
- tests/softlayer/models/compute/flavor_tests.rb
|
329
337
|
- tests/softlayer/models/compute/image_tests.rb
|
338
|
+
- tests/softlayer/models/compute/key_pair_tests.rb
|
330
339
|
- tests/softlayer/models/compute/server_tests.rb
|
331
340
|
- tests/softlayer/models/dns/domain_tests.rb
|
332
341
|
- tests/softlayer/models/dns/domains_tests.rb
|
@@ -335,6 +344,7 @@ files:
|
|
335
344
|
- tests/softlayer/models/storage/directory_tests.rb
|
336
345
|
- tests/softlayer/models/storage/file_tests.rb
|
337
346
|
- tests/softlayer/requests/compute/bmc_tests.rb
|
347
|
+
- tests/softlayer/requests/compute/key_pair_tests.rb
|
338
348
|
- tests/softlayer/requests/compute/tag_tests.rb
|
339
349
|
- tests/softlayer/requests/compute/vm_tests.rb
|
340
350
|
- tests/softlayer/requests/network/network_tests.rb
|