nephophobia 0.3.0 → 0.3.6

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.
Files changed (42) hide show
  1. data/lib/nephophobia.rb +26 -37
  2. data/lib/nephophobia/client.rb +6 -6
  3. data/lib/nephophobia/resource/compute.rb +209 -0
  4. data/lib/nephophobia/resource/credential.rb +68 -0
  5. data/lib/nephophobia/resource/image.rb +65 -0
  6. data/lib/nephophobia/resource/project.rb +132 -0
  7. data/lib/nephophobia/resource/role.rb +72 -0
  8. data/lib/nephophobia/resource/user.rb +83 -0
  9. data/lib/nephophobia/response/address.rb +13 -0
  10. data/lib/nephophobia/response/compute.rb +34 -0
  11. data/lib/nephophobia/response/credential.rb +17 -0
  12. data/lib/nephophobia/response/image.rb +24 -0
  13. data/lib/nephophobia/response/member.rb +15 -0
  14. data/lib/nephophobia/response/project.rb +18 -0
  15. data/lib/nephophobia/response/return.rb +16 -0
  16. data/lib/nephophobia/response/role.rb +15 -0
  17. data/lib/nephophobia/response/user.rb +17 -0
  18. data/lib/nephophobia/response/vnc.rb +11 -0
  19. data/lib/nephophobia/util.rb +12 -0
  20. data/lib/nephophobia/version.rb +1 -1
  21. data/nephophobia.gemspec +2 -2
  22. data/test/cassettes/compute_describe_addresses.yml +244 -0
  23. data/test/cassettes/compute_find.yml +30 -18
  24. data/test/cassettes/credential_import.yml +82 -0
  25. data/test/cassettes/role_all_no_params.yml +82 -0
  26. data/test/cassettes/role_modify_role.yml +190 -0
  27. data/test/dummy.pub +1 -0
  28. data/test/lib/nephophobia/{compute_test.rb → response/compute_test.rb} +39 -4
  29. data/test/lib/nephophobia/{credential_test.rb → response/credential_test.rb} +28 -1
  30. data/test/lib/nephophobia/{image_test.rb → response/image_test.rb} +1 -1
  31. data/test/lib/nephophobia/{project_test.rb → response/project_test.rb} +1 -1
  32. data/test/lib/nephophobia/{role_test.rb → response/role_test.rb} +57 -4
  33. data/test/lib/nephophobia/{user_test.rb → response/user_test.rb} +1 -1
  34. data/test/lib/{nephophobia_test.rb → nephophobia/util_test.rb} +3 -3
  35. data/test/test_helper.rb +7 -0
  36. metadata +45 -24
  37. data/lib/nephophobia/compute.rb +0 -243
  38. data/lib/nephophobia/credential.rb +0 -65
  39. data/lib/nephophobia/image.rb +0 -84
  40. data/lib/nephophobia/project.rb +0 -157
  41. data/lib/nephophobia/role.rb +0 -83
  42. data/lib/nephophobia/user.rb +0 -95
@@ -1,6 +1,6 @@
1
1
  require "test_helper"
2
2
 
3
- describe Nephophobia::User do
3
+ describe Nephophobia::Resource::User do
4
4
  ##
5
5
  # Note:
6
6
  # Assumes there is always at least one valid project.
@@ -1,17 +1,17 @@
1
1
  require "test_helper"
2
2
 
3
- describe Nephophobia do
3
+ describe Nephophobia::Util do
4
4
  describe "::coerce" do
5
5
  it "wraps a Hash with an Array" do
6
6
  hash = { :foo => :bar }
7
7
 
8
- Nephophobia.coerce(hash).must_equal [hash]
8
+ Nephophobia::Util.coerce(hash).must_equal [hash]
9
9
  end
10
10
 
11
11
  it "doesn't wrap others" do
12
12
  array = [:foo, :bar]
13
13
 
14
- Nephophobia.coerce(array).must_equal array
14
+ Nephophobia::Util.coerce(array).must_equal array
15
15
  end
16
16
  end
17
17
  end
@@ -8,6 +8,10 @@ require "nokogiri"
8
8
  require "vcr"
9
9
 
10
10
  class MiniTest::Unit::TestCase
11
+ def wait seconds = 5
12
+ sleep seconds unless VCR.current_cassette.record_mode == :none
13
+ end
14
+
11
15
  def cassette_for cassette, interaction = 0
12
16
  c = VCR::Cassette.new(cassette).send :recorded_interactions
13
17
  VCR.eject_cassette
@@ -18,8 +22,11 @@ end
18
22
 
19
23
  VCR.config do |c|
20
24
  c.stub_with :fakeweb
25
+
21
26
  c.cassette_library_dir = "test/cassettes"
22
27
  c.default_cassette_options = { :record => :none }
28
+
29
+ c.allow_http_connections_when_no_cassette = true
23
30
  end
24
31
 
25
32
  class Client
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: nephophobia
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.0
5
+ version: 0.3.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Dewey
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-05-27 00:00:00 -07:00
14
+ date: 2011-06-23 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -22,7 +22,7 @@ dependencies:
22
22
  requirements:
23
23
  - - ~>
24
24
  - !ruby/object:Gem::Version
25
- version: 2.6.0
25
+ version: 2.7.1
26
26
  type: :runtime
27
27
  version_requirements: *id001
28
28
  - !ruby/object:Gem::Dependency
@@ -83,7 +83,7 @@ dependencies:
83
83
  description: This gem is a simple binding to the EC2 API. It has specific extensions to allow extra functionality provided by OpenStack.
84
84
  email:
85
85
  - john@dewey.ws
86
- - jkleinpeter@attinteractive.com
86
+ - josh@kleinpeter.org
87
87
  executables: []
88
88
 
89
89
  extensions: []
@@ -101,12 +101,23 @@ files:
101
101
  - lib/hashify.rb
102
102
  - lib/nephophobia.rb
103
103
  - lib/nephophobia/client.rb
104
- - lib/nephophobia/compute.rb
105
- - lib/nephophobia/credential.rb
106
- - lib/nephophobia/image.rb
107
- - lib/nephophobia/project.rb
108
- - lib/nephophobia/role.rb
109
- - lib/nephophobia/user.rb
104
+ - lib/nephophobia/resource/compute.rb
105
+ - lib/nephophobia/resource/credential.rb
106
+ - lib/nephophobia/resource/image.rb
107
+ - lib/nephophobia/resource/project.rb
108
+ - lib/nephophobia/resource/role.rb
109
+ - lib/nephophobia/resource/user.rb
110
+ - lib/nephophobia/response/address.rb
111
+ - lib/nephophobia/response/compute.rb
112
+ - lib/nephophobia/response/credential.rb
113
+ - lib/nephophobia/response/image.rb
114
+ - lib/nephophobia/response/member.rb
115
+ - lib/nephophobia/response/project.rb
116
+ - lib/nephophobia/response/return.rb
117
+ - lib/nephophobia/response/role.rb
118
+ - lib/nephophobia/response/user.rb
119
+ - lib/nephophobia/response/vnc.rb
120
+ - lib/nephophobia/util.rb
110
121
  - lib/nephophobia/version.rb
111
122
  - nephophobia.gemspec
112
123
  - test/cassettes/compute_all.yml
@@ -116,6 +127,7 @@ files:
116
127
  - test/cassettes/compute_associate_address.yml
117
128
  - test/cassettes/compute_create.yml
118
129
  - test/cassettes/compute_create_with_optional_params.yml
130
+ - test/cassettes/compute_describe_addresses.yml
119
131
  - test/cassettes/compute_destroy.yml
120
132
  - test/cassettes/compute_disassociate_address.yml
121
133
  - test/cassettes/compute_find.yml
@@ -126,6 +138,7 @@ files:
126
138
  - test/cassettes/credential_all_without_keys.yml
127
139
  - test/cassettes/credential_create.yml
128
140
  - test/cassettes/credential_destroy.yml
141
+ - test/cassettes/credential_import.yml
129
142
  - test/cassettes/image_all.yml
130
143
  - test/cassettes/image_all_with_filter.yml
131
144
  - test/cassettes/image_find.yml
@@ -141,6 +154,7 @@ files:
141
154
  - test/cassettes/project_members_with_invalid_project_name.yml
142
155
  - test/cassettes/project_remove_member.yml
143
156
  - test/cassettes/role_all.yml
157
+ - test/cassettes/role_all_no_params.yml
144
158
  - test/cassettes/role_all_with_project_name.yml
145
159
  - test/cassettes/role_all_without_roles.yml
146
160
  - test/cassettes/role_create.yml
@@ -149,6 +163,7 @@ files:
149
163
  - test/cassettes/role_destroy.yml
150
164
  - test/cassettes/role_destroy_with_project_name.yml
151
165
  - test/cassettes/role_destroy_with_project_name_and_role_name.yml
166
+ - test/cassettes/role_modify_role.yml
152
167
  - test/cassettes/user_create.yml
153
168
  - test/cassettes/user_credentials.yml
154
169
  - test/cassettes/user_destroy.yml
@@ -156,15 +171,16 @@ files:
156
171
  - test/cassettes/user_find_with_invalid_user_name.yml
157
172
  - test/cassettes/user_register.yml
158
173
  - test/cassettes/user_register_asserts.yml
174
+ - test/dummy.pub
159
175
  - test/lib/aws_test.rb
160
176
  - test/lib/hashify_test.rb
161
- - test/lib/nephophobia/compute_test.rb
162
- - test/lib/nephophobia/credential_test.rb
163
- - test/lib/nephophobia/image_test.rb
164
- - test/lib/nephophobia/project_test.rb
165
- - test/lib/nephophobia/role_test.rb
166
- - test/lib/nephophobia/user_test.rb
167
- - test/lib/nephophobia_test.rb
177
+ - test/lib/nephophobia/response/compute_test.rb
178
+ - test/lib/nephophobia/response/credential_test.rb
179
+ - test/lib/nephophobia/response/image_test.rb
180
+ - test/lib/nephophobia/response/project_test.rb
181
+ - test/lib/nephophobia/response/role_test.rb
182
+ - test/lib/nephophobia/response/user_test.rb
183
+ - test/lib/nephophobia/util_test.rb
168
184
  - test/test_helper.rb
169
185
  has_rdoc: true
170
186
  homepage: http://github.com/retr0h/nephophobia
@@ -202,6 +218,7 @@ test_files:
202
218
  - test/cassettes/compute_associate_address.yml
203
219
  - test/cassettes/compute_create.yml
204
220
  - test/cassettes/compute_create_with_optional_params.yml
221
+ - test/cassettes/compute_describe_addresses.yml
205
222
  - test/cassettes/compute_destroy.yml
206
223
  - test/cassettes/compute_disassociate_address.yml
207
224
  - test/cassettes/compute_find.yml
@@ -212,6 +229,7 @@ test_files:
212
229
  - test/cassettes/credential_all_without_keys.yml
213
230
  - test/cassettes/credential_create.yml
214
231
  - test/cassettes/credential_destroy.yml
232
+ - test/cassettes/credential_import.yml
215
233
  - test/cassettes/image_all.yml
216
234
  - test/cassettes/image_all_with_filter.yml
217
235
  - test/cassettes/image_find.yml
@@ -227,6 +245,7 @@ test_files:
227
245
  - test/cassettes/project_members_with_invalid_project_name.yml
228
246
  - test/cassettes/project_remove_member.yml
229
247
  - test/cassettes/role_all.yml
248
+ - test/cassettes/role_all_no_params.yml
230
249
  - test/cassettes/role_all_with_project_name.yml
231
250
  - test/cassettes/role_all_without_roles.yml
232
251
  - test/cassettes/role_create.yml
@@ -235,6 +254,7 @@ test_files:
235
254
  - test/cassettes/role_destroy.yml
236
255
  - test/cassettes/role_destroy_with_project_name.yml
237
256
  - test/cassettes/role_destroy_with_project_name_and_role_name.yml
257
+ - test/cassettes/role_modify_role.yml
238
258
  - test/cassettes/user_create.yml
239
259
  - test/cassettes/user_credentials.yml
240
260
  - test/cassettes/user_destroy.yml
@@ -242,13 +262,14 @@ test_files:
242
262
  - test/cassettes/user_find_with_invalid_user_name.yml
243
263
  - test/cassettes/user_register.yml
244
264
  - test/cassettes/user_register_asserts.yml
265
+ - test/dummy.pub
245
266
  - test/lib/aws_test.rb
246
267
  - test/lib/hashify_test.rb
247
- - test/lib/nephophobia/compute_test.rb
248
- - test/lib/nephophobia/credential_test.rb
249
- - test/lib/nephophobia/image_test.rb
250
- - test/lib/nephophobia/project_test.rb
251
- - test/lib/nephophobia/role_test.rb
252
- - test/lib/nephophobia/user_test.rb
253
- - test/lib/nephophobia_test.rb
268
+ - test/lib/nephophobia/response/compute_test.rb
269
+ - test/lib/nephophobia/response/credential_test.rb
270
+ - test/lib/nephophobia/response/image_test.rb
271
+ - test/lib/nephophobia/response/project_test.rb
272
+ - test/lib/nephophobia/response/role_test.rb
273
+ - test/lib/nephophobia/response/user_test.rb
274
+ - test/lib/nephophobia/util_test.rb
254
275
  - test/test_helper.rb
@@ -1,243 +0,0 @@
1
- module Nephophobia
2
- class ComputeData
3
- attr_reader :description, :dns_name, :image_id, :instance_id, :instance_type
4
- attr_reader :key_name, :launch_time, :name, :owner_id, :placement
5
- attr_reader :private_dns_name, :project_id, :public_dns_name, :state
6
-
7
- attr_accessor :attributes
8
-
9
- def initialize attributes
10
- @attributes = attributes
11
-
12
- @project_id = attributes['ownerId']
13
- item = attributes['instancesSet']['item']
14
- item = item.first if item.is_a?(Array)
15
- @description = item['displayDescription']
16
- @name = item['displayName']
17
- @key_name = item['keyName']
18
- @instance_id = item['instanceId']
19
- @state = item['instanceState']['name']
20
- @public_dns_name = item['publicDnsName']
21
- @private_dns_name = item['privateDnsName']
22
- @image_id = item['imageId']
23
- @dns_name = item['dnsName']
24
- @launch_time = DateTime.parse(item['launchTime'])
25
- @placement = item['placement']['availabilityZone']
26
- @instance_type = item['instanceType']
27
- end
28
- end
29
-
30
- class VncData
31
- attr_reader :attributes, :url
32
-
33
- def initialize attributes
34
- @url = attributes['url']
35
- end
36
- end
37
-
38
- class AddressData
39
- attr_reader :attributes, :floating_ip, :status
40
-
41
- def initialize attributes
42
- @floating_ip = attributes['publicIp']
43
- @status = attributes['item']
44
- end
45
- end
46
-
47
- class Compute
48
- def initialize client
49
- @client = client
50
- end
51
-
52
- ##
53
- # Returns information about instances that +@client+ owns.
54
- #
55
- # +filter+: An optional Hash, intended for filtering.
56
- # See the API Reference for further details.
57
- # {
58
- # "Filter.1.Name" => "instance-type",
59
- # "Filter.1.Value.1" => "m1.small"
60
- # }
61
-
62
- def all filter = {}
63
- response = @client.action "DescribeInstances", filter
64
-
65
- item = response.body['DescribeInstancesResponse']['reservationSet']['item']
66
- Nephophobia.coerce(item).collect do |data|
67
- ComputeData.new data
68
- end
69
- end
70
-
71
- ##
72
- # Create a compute instance with the given 'image_id'.
73
- # Returns information about the new instance.
74
- #
75
- # +image_id+: A String representing the ID of the image.
76
- # +params+: An optional Hash.
77
- # See the API Reference for further details.
78
- # {
79
- # "DisplayName" => "testserver1",
80
- # "DisplayDescription" => "test description"
81
- # }
82
-
83
- def create image_id, params = {}
84
- response = @client.action "RunInstances", { "ImageId" => image_id }.merge(params)
85
-
86
- ComputeData.new response.body['RunInstancesResponse']
87
- end
88
-
89
- ##
90
- # Removes the given 'instance_id'.
91
- # Returns instances response to a state change.
92
- #
93
- # +instance_id+: A String representing the ID of the instance.
94
-
95
- def destroy instance_id
96
- params = {
97
- "InstanceId.1" => instance_id
98
- }
99
-
100
- response = @client.action "TerminateInstances", params
101
-
102
- ResponseData.new response.body['TerminateInstancesResponse']
103
- end
104
-
105
- ##
106
- # Returns information about the given 'instance_id'.
107
- #
108
- # +instance_id+: A String representing the ID of the instance.
109
-
110
- def find instance_id
111
- params = {
112
- "InstanceId.1" => instance_id
113
- }
114
-
115
- response = @client.action "DescribeInstances", params
116
-
117
- ComputeData.new response.body['DescribeInstancesResponse']['reservationSet']['item']
118
- end
119
-
120
- ##
121
- # Reboot the given 'instance_id'.
122
- # Returns instances response to a state change.
123
- #
124
- # +instance_id+: A String representing the ID of the instance.
125
-
126
- def reboot instance_id
127
- params = {
128
- "InstanceId.1" => instance_id
129
- }
130
-
131
- response = @client.action "RebootInstances", params
132
-
133
- ResponseData.new response.body['RebootInstancesResponse']
134
- end
135
-
136
- ##
137
- # Starts the given 'instance_id'.
138
- # Returns instances current and previous state.
139
- #
140
- # +instance_id+: A String representing the ID of the instance.
141
-
142
- def start instance_id
143
- params = {
144
- "InstanceId.1" => instance_id
145
- }
146
-
147
- response = @client.action "StopInstances", params
148
-
149
- ResponseData.new response.body
150
- end
151
-
152
- ##
153
- # Stops the given 'instance_id'
154
- # Returns instances current and previous state.
155
- #
156
- # +instance_id+: A String representing the ID of the instance.
157
-
158
- def stop instance_id
159
- params = {
160
- "InstanceId.1" => instance_id
161
- }
162
-
163
- response = @client.action "StartInstances", params
164
-
165
- ResponseData.new response.body
166
- end
167
-
168
- ##
169
- # Returns the VNC browser URL. Used by the Portal.
170
- # __Must__ execute as a user with the +admin+ role.
171
- #
172
- # +instance_id+: A String representing the ID of the instance.
173
-
174
- def vnc_url instance_id
175
- params = {
176
- "InstanceId" => instance_id
177
- }
178
-
179
- response = @client.action "GetVncConsole", params
180
-
181
- VncData.new response.body['GetVncConsoleResponse']
182
- end
183
-
184
- ##
185
- # Acquires an elastic IP address.
186
- # Returns an elastic IP.
187
-
188
- def allocate_address
189
- response = @client.action "AllocateAddress", {}
190
-
191
- AddressData.new response.body['AllocateAddressResponse']
192
- end
193
-
194
- ##
195
- # Releases an elastic IP address.
196
- #
197
- # +floating_ip+: A String representing a floating IP address.
198
-
199
- def release_address floating_ip
200
- params = {
201
- "PublicIp" => floating_ip
202
- }
203
-
204
- response = @client.action "ReleaseAddress", params
205
-
206
- AddressData.new response.body['ReleaseAddressResponse']['releaseResponse']
207
- end
208
-
209
- ##
210
- # Associates an elastic IP address with an instance.
211
- #
212
- # +instance_id+: A String representing the ID of the instance.
213
- # +floating_ip+: A String representing a floating IP address.
214
-
215
- def associate_address instance_id, floating_ip
216
- params = {
217
- "InstanceId" => instance_id,
218
- "PublicIp" => floating_ip
219
- }
220
-
221
- response = @client.action "AssociateAddress", params
222
-
223
- AddressData.new response.body['AssociateAddressResponse']['associateResponse']
224
- end
225
-
226
- ##
227
- # Disassociates the specified elastic IP address from the instance
228
- # to which it is assigned.
229
- #
230
- # +instance_id+: A String representing the ID of the instance.
231
- # +floating_ip+: A String representing a floating IP address.
232
-
233
- def disassociate_address floating_ip
234
- params = {
235
- "PublicIp" => floating_ip
236
- }
237
-
238
- response = @client.action "DisassociateAddress", params
239
-
240
- AddressData.new response.body['DisassociateAddressResponse']['disassociateResponse']
241
- end
242
- end
243
- end