fog-maestrodev 1.18.0.20131121075022 → 1.18.0.20131122203507

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +8 -8
  2. data/fog.gemspec +2 -2
  3. data/lib/fog/aws/models/auto_scaling/configuration.rb +1 -0
  4. data/lib/fog/aws/models/compute/flavors.rb +10 -0
  5. data/lib/fog/aws/models/glacier/vault.rb +1 -1
  6. data/lib/fog/aws/parsers/auto_scaling/describe_launch_configurations.rb +3 -0
  7. data/lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb +1 -0
  8. data/lib/fog/aws/requests/dns/get_change.rb +1 -1
  9. data/lib/fog/aws/storage.rb +2 -1
  10. data/lib/fog/core/errors.rb +3 -3
  11. data/lib/fog/dreamhost/dns.rb +2 -4
  12. data/lib/fog/google/compute.rb +72 -62
  13. data/lib/fog/google/models/compute/zones.rb +1 -1
  14. data/lib/fog/google/requests/compute/delete_disk.rb +19 -2
  15. data/lib/fog/google/requests/compute/delete_server.rb +3 -3
  16. data/lib/fog/google/requests/compute/get_disk.rb +26 -2
  17. data/lib/fog/google/requests/compute/get_image.rb +3 -3
  18. data/lib/fog/google/requests/compute/get_server.rb +1 -0
  19. data/lib/fog/google/requests/compute/insert_disk.rb +37 -2
  20. data/lib/fog/google/requests/compute/insert_firewall.rb +2 -1
  21. data/lib/fog/google/requests/compute/insert_image.rb +1 -1
  22. data/lib/fog/google/requests/compute/insert_server.rb +31 -22
  23. data/lib/fog/google/requests/compute/list_disks.rb +8 -2
  24. data/lib/fog/google/requests/compute/list_images.rb +2 -2
  25. data/lib/fog/google/requests/compute/list_machine_types.rb +2 -2
  26. data/lib/fog/google/requests/compute/list_servers.rb +2 -2
  27. data/lib/fog/google/requests/compute/list_zone_operations.rb +1 -1
  28. data/lib/fog/google/requests/compute/list_zones.rb +1 -1
  29. data/lib/fog/hp.rb +1 -1
  30. data/lib/fog/hp/README.md +57 -0
  31. data/lib/fog/hp/articles/auth_caching.md +23 -0
  32. data/lib/fog/hp/docs/connect.md +152 -0
  33. data/lib/fog/hp/docs/install.md +133 -0
  34. data/lib/fog/hp/examples/block_storage.md +296 -0
  35. data/lib/fog/hp/examples/block_storage_v2.md +446 -0
  36. data/lib/fog/hp/examples/cdn.md +54 -0
  37. data/lib/fog/hp/examples/compute.md +794 -0
  38. data/lib/fog/hp/examples/compute_v2.md +848 -0
  39. data/lib/fog/hp/examples/getting_started_examples.md +30 -0
  40. data/lib/fog/hp/examples/networking.md +472 -0
  41. data/lib/fog/hp/examples/object_storage.md +387 -0
  42. data/lib/fog/json.rb +6 -3
  43. data/lib/fog/openstack/identity.rb +2 -3
  44. data/lib/fog/openstack/image.rb +1 -4
  45. data/lib/fog/openstack/metering.rb +1 -4
  46. data/lib/fog/openstack/network.rb +1 -3
  47. data/lib/fog/openstack/requests/compute/add_flavor_access.rb +1 -1
  48. data/lib/fog/openstack/requests/compute/allocate_address.rb +1 -1
  49. data/lib/fog/openstack/requests/compute/attach_volume.rb +1 -1
  50. data/lib/fog/openstack/requests/compute/boot_from_snapshot.rb +1 -1
  51. data/lib/fog/openstack/requests/compute/create_flavor.rb +1 -1
  52. data/lib/fog/openstack/requests/compute/create_key_pair.rb +1 -1
  53. data/lib/fog/openstack/requests/compute/create_security_group.rb +1 -1
  54. data/lib/fog/openstack/requests/compute/create_security_group_rule.rb +1 -1
  55. data/lib/fog/openstack/requests/compute/create_volume.rb +1 -1
  56. data/lib/fog/openstack/requests/compute/create_volume_snapshot.rb +1 -1
  57. data/lib/fog/openstack/requests/compute/list_tenants.rb +1 -1
  58. data/lib/fog/openstack/requests/compute/remove_flavor_access.rb +1 -1
  59. data/lib/fog/openstack/requests/compute/update_quota.rb +1 -1
  60. data/lib/fog/openstack/requests/identity/create_ec2_credential.rb +1 -1
  61. data/lib/fog/openstack/requests/identity/create_role.rb +1 -1
  62. data/lib/fog/openstack/requests/identity/create_user.rb +1 -1
  63. data/lib/fog/openstack/requests/identity/update_user.rb +1 -1
  64. data/lib/fog/openstack/requests/image/update_image_members.rb +1 -1
  65. data/lib/fog/openstack/requests/orchestration/create_stack.rb +2 -2
  66. data/lib/fog/openstack/requests/orchestration/update_stack.rb +1 -1
  67. data/lib/fog/openstack/requests/volume/create_volume.rb +1 -1
  68. data/lib/fog/openstack/requests/volume/create_volume_snapshot.rb +1 -1
  69. data/lib/fog/openstack/volume.rb +1 -4
  70. data/lib/fog/rackspace/compute_v2.rb +1 -0
  71. data/lib/fog/rackspace/examples/queues/claim_messages.rb +60 -0
  72. data/lib/fog/rackspace/examples/queues/create_queue.rb +45 -0
  73. data/lib/fog/rackspace/examples/queues/delete_message.rb +72 -0
  74. data/lib/fog/rackspace/examples/queues/delete_queue.rb +53 -0
  75. data/lib/fog/rackspace/examples/queues/list_messages.rb +64 -0
  76. data/lib/fog/rackspace/examples/queues/post_message.rb +59 -0
  77. data/lib/fog/rackspace/models/queues/claim.rb +2 -0
  78. data/lib/fog/rackspace/models/queues/message.rb +5 -5
  79. data/lib/fog/rackspace/models/queues/queue.rb +1 -1
  80. data/lib/fog/rackspace/service.rb +1 -1
  81. data/lib/fog/riakcs.rb +2 -2
  82. data/lib/fog/riakcs/provisioning.rb +1 -3
  83. data/lib/fog/riakcs/requests/provisioning/create_user.rb +2 -2
  84. data/lib/fog/riakcs/requests/provisioning/get_user.rb +1 -1
  85. data/lib/fog/riakcs/requests/provisioning/list_users.rb +1 -1
  86. data/lib/fog/riakcs/requests/usage/get_usage.rb +1 -1
  87. data/lib/fog/riakcs/usage.rb +0 -2
  88. data/lib/fog/vsphere/compute.rb +1 -0
  89. data/lib/fog/vsphere/models/compute/datastore.rb +1 -0
  90. data/lib/fog/vsphere/requests/compute/list_datastores.rb +9 -8
  91. data/lib/fog/vsphere/requests/compute/set_vm_customvalue.rb +19 -0
  92. data/lib/tasks/changelog_task.rb +0 -1
  93. data/tests/google/models/compute/disk_tests.rb +5 -0
  94. data/tests/google/models/compute/disks_tests.rb +5 -0
  95. data/tests/google/models/compute/server_tests.rb +3 -0
  96. data/tests/google/models/compute/servers_tests.rb +5 -0
  97. data/tests/google/requests/compute/disk_tests.rb +2 -1
  98. data/tests/google/requests/compute/firewall_tests.rb +1 -0
  99. data/tests/google/requests/compute/image_tests.rb +3 -0
  100. data/tests/google/requests/compute/network_tests.rb +1 -0
  101. data/tests/google/requests/compute/operation_tests.rb +1 -0
  102. data/tests/google/requests/compute/server_tests.rb +2 -3
  103. data/tests/google/requests/compute/zone_tests.rb +1 -6
  104. data/tests/helpers/mock_helper.rb +3 -4
  105. data/tests/rackspace/models/queues/message_tests.rb +16 -0
  106. data/tests/vsphere/requests/compute/set_vm_customvalue_tests.rb +21 -0
  107. metadata +29 -3
  108. data/lib/fog/hp/README_HP.rdoc +0 -61
@@ -0,0 +1,387 @@
1
+ # Examples for working with HP Cloud Object Storage Service
2
+
3
+ The HP Cloud Extensions to Ruby Fog libary provides Object Storage services support using two abstractions: a model layer and a request layer. Executing commands in both layers are detailed in this page.
4
+
5
+ The examples on this page can be executed from within a Ruby console (IRB):
6
+
7
+ irb
8
+
9
+ This page discusses the following topics:
10
+
11
+ * [Connecting to the Service](https://github.com/fog/fog/blob/master/lib/fog/hp/docs/connect.md)
12
+ * [Using the Model Abstraction](#using-the-model-abstraction)
13
+ * [Using the Request Abstraction](#using-the-request-abstraction)
14
+
15
+
16
+ ## Using the Model Abstraction
17
+
18
+ 1. List all directories/containers for the given account
19
+
20
+ dirs = conn.directories
21
+ dirs.size # returns no. of directories
22
+
23
+ 2. Create a new directory/container
24
+
25
+ conn.directories.create(:key => "fog-rocks")
26
+
27
+ 3. View a directory/container
28
+
29
+ dir = conn.directories.get("fog-rocks")
30
+ dir.key # => fog-rocks
31
+
32
+ 4. Apply ACLs on an existing directory/container
33
+
34
+ dir = conn.directories.get("fog-rocks")
35
+ dir.public = true
36
+ dir.save
37
+ dir.public? # => true
38
+ dir.public = false # toggles between "private" and "public-read" acl on a directory
39
+ dir.save
40
+ dir.public? # => false
41
+
42
+ 5. Create a new file/object into an existing directory/container
43
+
44
+ dir = conn.directories.get("fog-rocks")
45
+ dir.files.create(:key => "sample.txt", :body => File.open("/path/to/sample.txt"))
46
+
47
+ 6. View a file/object from an existing directory/container
48
+
49
+ dir = conn.directories.get("fog-rocks")
50
+ file = dir.files.get("sample.txt")
51
+ file.key # => sample.txt
52
+
53
+ 7. Copy a file/object into an existing directory/container
54
+
55
+ file = conn.directories.get("fog-rocks").files.get("sample.txt")
56
+ other_file = file.copy("fog-rocks", "another-sample.txt")
57
+ other_file.key # => another-sample.txt
58
+
59
+ 8. View the files/objects for a directory/container
60
+
61
+ dir = conn.directories.get("fog-rocks")
62
+ files = dir.files
63
+ files.directory.key # => fog-rocks
64
+ files.size # returns no. of files
65
+ files[0].key # key of the file in collection
66
+ files[0].content_length # content length of file
67
+ files[0].last_modified # last modified date in UTC
68
+
69
+ 9. Generate a temporary URL for a file or object for sharing purposes
70
+
71
+ dir = conn.directories.get("fog-rocks")
72
+ file = dir.files.get("sample.txt")
73
+ # creates a TempUrl to access sample.txt and access expires in 240 secs
74
+ file.temp_signed_url(240, "GET")
75
+
76
+ 10. Delete a file/object from an existing directory/container
77
+
78
+ dir = conn.directories.get("fog-rocks")
79
+ file = dir.files.get("sample.txt")
80
+ file.destroy
81
+ # chaining a series of calls to delete a file
82
+ conn.directories.get("fog-rocks").files.get("another-sample.txt").destroy
83
+
84
+ 11. Delete an existing directory/container
85
+
86
+ # Note: directory needs to be empty before it can be deleted!
87
+ conn.directories.get("fog-rocks").destroy
88
+
89
+ **Note**: You cannot use the create, update, or delete operations on a shared container.
90
+
91
+ ### About using object ACLs
92
+
93
+ Object ACLs allow you to share containers and objects with other registered HP Public Cloud users. The owner of a container or object can grant read, write, read/write access to other users. The shared containers and objects can then be accessed based on the permissions granted by the owner.
94
+
95
+ ### Using the object ACLs to grant access
96
+
97
+ To grant access to an object or a container:
98
+
99
+ mydir = conn.directories.get('rgtest2') # grant uses username
100
+ mydir.grant("rw", ["someuser"])
101
+ mydir.save # share the url for access to container
102
+ mydir.public_url
103
+ # => "https://objects.xxxx.hpcloud.net:443/v1/1111111/rgtest2"
104
+
105
+ myfile = mydir.files.get("sample.txt") # share the url for access to object
106
+ myfile.public_url
107
+ # => "https://objects.xxxx.hpcloud.net:443/v1/1111111/rgtest2/sample.txt"
108
+
109
+ ### Using the object ACLs to access shared objects
110
+
111
+ 1. Use the shared URLs to get the contents of a shared container:
112
+
113
+ sd = conn.shared_directories.get(mydir.public_url)
114
+ sd.url
115
+ # => "https://objects.xxxx.hpcloud.net:443/v1/1111111/rgtest2"
116
+ sd.files
117
+
118
+ **Note**: If the grantee does not have access, the system generates an exception of type `Fog::HP::Errors::Forbidden`.
119
+
120
+ 2. Use the shared URLs to get the metadata for a container:
121
+
122
+ sd = conn.shared_directories.head(mydir.public_url)
123
+
124
+ **Note**: If the grantee does not have access, the system generates an exception of type `Fog::HP::Errors::Forbidden`.
125
+
126
+ 3. Use the shared URLs to get the contents of a shared object:
127
+
128
+ sd = conn.shared_directories.get(mydir.public_url)
129
+ sf = sd.files.get('sample.txt')
130
+
131
+ 4. Use the shared URLs to get the metadata for a shared object:
132
+
133
+ sd = conn.shared_directories.get(mydir.public_url)
134
+ sf = sd.files.head('sample.txt')
135
+
136
+ 5. Use the shared URLs to put a new object or file into a shared container:
137
+
138
+ sd = conn.shared_directories.get(mydir.public_url)
139
+ sf = sd.files.create(:key => 'tiny2.txt', :body => "This is another text file.")
140
+
141
+ **Note**: If the grantee does not have access, the system generates an exception of type `Fog::HP::Errors::Forbidden`.
142
+
143
+ 6. Use the shared URLs to update an existing object or file in a shared container:
144
+
145
+ sd = conn.shared_directories.get(mydir.public_url)
146
+ sf = sd.files.new(:key => 'sample.txt')
147
+ sf.body = "This is another text file."
148
+ sf.save
149
+
150
+ **Note**: If the grantee does not have access, the system generates an exception of type `Fog::HP::Errors::Forbidden`.
151
+
152
+ 7. Use the shared URLs to delete an existing object or file from a shared container:
153
+
154
+ sd = conn.shared_directories.get(mydir.public_url)
155
+ sd.destroy
156
+
157
+ ### Synchronize containers across regions
158
+
159
+ Synchronizing containers creates a one-way association from containers to the sync objects. The sync operation is performed by a background process on the container server. You must perform a one-time setup to set the metadata on the containers for syncing.
160
+
161
+ 1. One-Way sync of containers (from source to target only):
162
+
163
+ # create source and target containers
164
+ conn.directories.create(:key => 'imp_stuff')
165
+ conn.directories.create(:key => 'sync_archive')
166
+ dir = conn.directories.get('imp_stuff')
167
+ target_dir = conn.directories.get('sync_archive')
168
+
169
+ # create some objects in the source container
170
+ dir.files.create(:key => 'imp_1.txt', :body => "This is a small file but it is very important.")
171
+ dir.files.create(:key => 'imp_2.txt', :body => "This is another small file but it is very important as well.")
172
+
173
+ # sync the source -> target
174
+ dir.sync(target_dir, "boogieman") # => true
175
+ dir.save # => true
176
+
177
+ 2. Two-Way sync of containers (from source to target and back):
178
+
179
+ # Now, lets do a two way sync between dir and target containers
180
+ dir = conn.directories.get('imp_stuff')
181
+ target_dir = conn.directories.get('sync_archive')
182
+
183
+ # sync the target -> source
184
+ target_dir.sync(dir, "boogieman") # => true
185
+ target_dir.save # => true
186
+
187
+ 3. One and two-way sync of containers across regions:
188
+
189
+ # assuming source container exists in region-a
190
+ dir_a = conn.directories.get('imp_stuff') # Note: conn points to region-a
191
+ # assuming target container exists in region-a
192
+ target_dir_b = conn2.directories.get('arch_imp_stuff') # Note: conn2 points to region-b
193
+
194
+ # sync the source -> target
195
+ dir_a.sync(target_dir_b, "boogieman") # => true
196
+ dir_a.save # => true
197
+
198
+ # sync the target -> source
199
+ target_dir_b.sync(dir_a, "boogieman") # => true
200
+ target_dir_b.save #=> true
201
+
202
+
203
+ ## Using the Request Abstraction
204
+
205
+ 1. List all container for the given account:
206
+
207
+ response = conn.get_containers
208
+ response.body # returns an array of container hash objects
209
+ response.body[0]["name"] # returns the name of the container
210
+ response.body[0]["count"] # returns the number of objects in the container
211
+ response.body[0]["bytes"] # returns the total bytes for the objects in the container
212
+
213
+ 2. Create a new container:
214
+
215
+ container = conn.put_container("fog-rocks") # creates the container
216
+ container.headers # returns a hash of headers
217
+ container.headers["Content-Length"] # returns the content-length
218
+
219
+ 3. View a container:
220
+
221
+ container = conn.get_container("fog-rocks")
222
+ container.body # returns an array of objects hash
223
+ container.body[0]['name'] # returns the name of the object
224
+ container.headers # returns a hash of headers
225
+ container.headers["Content-Length"] # returns the content-length
226
+ container.headers["Content-Type"] # returns the content-type
227
+ container.headers["X-Container-Object-Count"] # returns the number of objects in the container
228
+ container.headers["X-Container-Bytes-Used"] # returns the total bytes for the objects in the container
229
+ container.status # HTTP status code for the operation
230
+
231
+ 4. View the container's headers and metadata without getting the content:
232
+
233
+ container = conn.head_container("fog-rocks")
234
+ container.body # returns an empty body
235
+ container.headers # returns a hash of headers
236
+ container.headers["Content-Length"] # returns the content-length
237
+ container.headers["Content-Type"] # returns the content-type
238
+ container.status # HTTP status code for the operation
239
+
240
+ 5. Create a new file into an existing container:
241
+
242
+ file = conn.put_object("fog-rocks", "sample.txt", File.open('/path/to/file/sample.txt'))
243
+ file.headers # returns a hash of headers
244
+ file.headers["Content-Length"] # returns the content-length
245
+
246
+ 6. View a file from an existing container:
247
+
248
+ file = conn.get_object("fog-rocks", "sample.txt")
249
+ file.body # returns the contents of the file
250
+ file.headers # returns a hash of headers
251
+ file.headers["Content-Length"] # returns the content-length
252
+ file.headers["Content-Type"] # returns the content-type
253
+ file.status # HTTP status code for the operation
254
+
255
+ 7. View the file's headers and metadata without getting the content:
256
+
257
+ file = conn.head_object("fog-rocks", "sample.txt")
258
+ file.body # returns the empty body
259
+ file.headers # returns a hash of headers
260
+ file.headers["Content-Length"] # returns the content-length
261
+ file.headers["Content-Type"] # returns the content-type
262
+ file.status # HTTP status code for the operation
263
+
264
+ 8. Copy a file within the same container:
265
+
266
+ # copy an object
267
+ conn.put_object("fog-rocks", "another-sample.txt", nil, {'X-Copy-From' => "/fog-rocks/sample.txt" })
268
+ # get the copied object
269
+ other_file = conn.get_object("fog-rocks", "another-sample.txt")
270
+ other_file.headers # returns a hash of headers
271
+ other_file.headers["Content-Length"] # returns the content-length
272
+
273
+ 9. Copy a file from one container to another container:
274
+
275
+ # create a new container
276
+ conn.put_container("fog-rocks-2") # creates the other new container
277
+ # copy the object
278
+ conn.put_object("fog-rocks-2", "sample.txt", nil, {'X-Copy-From' => "/fog-rocks/sample.txt" })
279
+ # get the copied object
280
+ other_file = conn.get_object("fog-rocks-2", "sample.txt")
281
+ other_file.headers # returns a hash of headers
282
+ other_file.headers["Content-Length"] # returns the content-length
283
+
284
+ 10. Generate a temporary URL for a file or object for sharing purposes:
285
+
286
+ # creates a TempUrl to access sample.txt and access expires in 240 secs
287
+ conn.get_object_temp_url("fog-rocks", "sample.txt", 240, "GET")
288
+
289
+ 11. Delete a file from an existing container:
290
+
291
+ conn.delete_object("fog-rocks", "sample.txt")
292
+ conn.delete_object("fog-rocks", "another-sample.txt")
293
+
294
+ 12. Delete an existing container:
295
+
296
+ # Note: a container needs to be empty before it can be deleted!
297
+ conn.delete_container("fog-rocks")
298
+
299
+ ### Using Object ACLs
300
+
301
+ To use object ACLs in the request abstraction layer, you need to have already been granted permission to access the objects or containers. (See the section on [Using Object ACLs](#UsingObjectACLsModelLayer) in the Model Layer section above for information on granting access.)
302
+
303
+ 1. Use the shared URLs to get the contents of a shared container:
304
+
305
+ conn.get_shared_container(mydir.public_url)
306
+
307
+ **Note**: If the grantee does not have access, the system generates an exception of type `Fog::HP::Errors::Forbidden`.
308
+
309
+ 2. Use the shared URLs to get the metadata of a shared container:
310
+
311
+ conn.head_shared_container(mydir.public_url)
312
+
313
+ **Note**: If the grantee does not have access, the system generates an exception of type `Fog::HP::Errors::Forbidden`.
314
+
315
+ 3. Use the shared URLs to get the contents of a shared object:
316
+
317
+ conn.get_shared_object(myfile.public_url)
318
+
319
+ 4. Use the shared URLs to get the metadata for a shared object
320
+
321
+ conn.head_shared_object(myfile.public_url)
322
+
323
+ 5. Use the shared URLs to put a new object or file into a shared container:
324
+
325
+ conn.put_shared_object(mydir.public_url, 'tiny.txt', File.read('tiny.txt'))
326
+
327
+ **Note**: If the grantee does not have access, the system generates an exception of type `Fog::HP::Errors::Forbidden`.
328
+
329
+ 6. Use the shared URLs to update an existing object or file in a shared container:
330
+
331
+ conn.put_shared_object(mydir.public_url, 'sample.txt', "This text needed some update.")
332
+
333
+ **Note**: If the grantee does not have access, the system generates an exception of type `Fog::HP::Errors::Forbidden`.
334
+
335
+ 7. Use the shared URLs to delete an existing object or file from a shared container:
336
+
337
+ conn.delete_shared_object(myfile.public_url)
338
+
339
+ ### Synchronize containers across regions
340
+
341
+ Synchronizing containers creates a one-way association from containers to the sync objects. The sync operation is performed by a background process on the container server. You must perform a one-time setup to set the metadata on the containers for syncing.
342
+
343
+ 1. One-Way sync of containers (from source to target only):
344
+
345
+ # create source and target containers
346
+ conn.put_container('imp_stuff')
347
+ conn.put_container('sync_archive')
348
+
349
+ # create some objects in the source container
350
+ conn.put_object('imp_stuff', 'imp_1.txt', "This is a small file but it is very important.")
351
+ conn.put_object('imp_stuff', 'imp_2.txt', File.open('/path/to/file/imp_2.txt'))
352
+
353
+ # to sync we need to put some metadata on the source and target containers
354
+ conn.put_container('imp_stuff',
355
+ {'X-Container-Sync-To' => "/url/to/the/target/sync_archive",
356
+ 'X-Container-Sync-Key' => 'boogieman'})
357
+ conn.put_container('sync_archive',
358
+ {'X-Container-Sync-Key' => 'boogieman'})
359
+
360
+ 2. Two-Way sync of containers (from source to target and visa-versa):
361
+
362
+ # Now, lets do a two way sync between dir and target containers
363
+ # to sync we need to put some metadata on the source and target containers
364
+ conn.put_container('imp_stuff',
365
+ {'X-Container-Sync-To' => "/url/to/the/target/sync_archive",
366
+ 'X-Container-Sync-Key' => 'boogieman'})
367
+ conn.put_container('sync_archive',
368
+ {'X-Container-Sync-To' => "/url/to/the/source/imp_stuff",
369
+ 'X-Container-Sync-Key' => 'boogieman'})
370
+
371
+ 3. One and two-way sync of containers across regions:
372
+
373
+ # assuming source container exists in region-a
374
+ conn.get_container('imp_stuff') # Note: conn points to region-a
375
+ # create a new container in region-b
376
+ conn2.put_container('arch_imp_stuff') # Note: conn2 points to region-b
377
+
378
+ # to sync we need to put some metadata on the source and target containers
379
+ conn.put_container('imp_stuff',
380
+ {'X-Container-Sync-To' => "/region-b/url/to/the/target/arch_imp_stuff",
381
+ 'X-Container-Sync-Key' => 'boogieman'})
382
+ conn2.put_container('arch_imp_stuff',
383
+ {'X-Container-Sync-To' => "/region-a/url/to/the/source/imp_stuff",
384
+ 'X-Container-Sync-Key' => 'boogieman'})
385
+
386
+ ---------
387
+ [Documentation Home](https://github.com/fog/fog/blob/master/lib/fog/hp/README.md) | [Examples](https://github.com/fog/fog/blob/master/lib/fog/hp/examples/getting_started_examples.md)
data/lib/fog/json.rb CHANGED
@@ -10,10 +10,9 @@ module Fog
10
10
  # The intent is to provide common code for provider APIs using JSON but not
11
11
  # require it for those using XML.
12
12
  #
13
- # @todo Add +require "fog/json" and/or +include Fog::JSON+ to providers using
14
- # its services
15
- #
16
13
  module JSON
14
+ class EncodeError < Fog::Errors::Error; end
15
+ class DecodeError < Fog::Errors::Error; end
17
16
 
18
17
  def self.sanitize(data)
19
18
  case data
@@ -35,10 +34,14 @@ module Fog
35
34
 
36
35
  def self.encode(obj)
37
36
  MultiJson.encode(obj)
37
+ rescue => err
38
+ raise EncodeError.slurp(err)
38
39
  end
39
40
 
40
41
  def self.decode(obj)
41
42
  MultiJson.decode(obj)
43
+ rescue => err
44
+ raise DecodeError.slurp(err)
42
45
  end
43
46
  end
44
47
  end
@@ -95,7 +95,6 @@ module Fog
95
95
  end
96
96
 
97
97
  def initialize(options={})
98
- require 'multi_json'
99
98
  @openstack_username = options[:openstack_username] || 'admin'
100
99
  @openstack_tenant = options[:openstack_tenant] || 'admin'
101
100
  @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
@@ -245,7 +244,7 @@ module Fog
245
244
  end
246
245
  end
247
246
  unless response.body.empty?
248
- response.body = MultiJson.decode(response.body)
247
+ response.body = Fog::JSON.decode(response.body)
249
248
  end
250
249
  response
251
250
  end
@@ -292,4 +291,4 @@ module Fog
292
291
  end
293
292
  end
294
293
  end
295
- end
294
+ end
@@ -46,7 +46,6 @@ module Fog
46
46
  end
47
47
 
48
48
  def initialize(options={})
49
- require 'multi_json'
50
49
  @openstack_username = options[:openstack_username]
51
50
  @openstack_tenant = options[:openstack_tenant]
52
51
  @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
@@ -94,8 +93,6 @@ module Fog
94
93
  attr_reader :current_tenant
95
94
 
96
95
  def initialize(options={})
97
- require 'multi_json'
98
-
99
96
  @openstack_auth_token = options[:openstack_auth_token]
100
97
 
101
98
  unless @openstack_auth_token
@@ -167,7 +164,7 @@ module Fog
167
164
  end
168
165
  end
169
166
  unless response.body.empty?
170
- response.body = MultiJson.decode(response.body)
167
+ response.body = Fog::JSON.decode(response.body)
171
168
  end
172
169
  response
173
170
  end